Last active
April 19, 2018 04:42
-
-
Save filewalkwithme/c66c797e3b1b874247273f6fc4e5a912 to your computer and use it in GitHub Desktop.
Extract CVE numbers from a target string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"regexp" | |
) | |
func main() { | |
// https://cve.mitre.org/cve/identifiers/tech-guidance.html#extraction_or_parsing | |
var cveRegex = regexp.MustCompile(`(?i)(CVE-\d{4}-(0\d{3}|[1-9]\d{3,}))`) | |
fmt.Println(cveRegex.FindAllString("Lorem ipsum CVE-2001-1234, dolor sit amet CVE-2002-4567, vel ea tale iriure deseruisse.", -1)) | |
fmt.Println(cveRegex.FindAllString("Usu et simul alterum offendit. Mei eu nobis CVE-2003-8989invidunt patrioque.", -1)) | |
fmt.Println(cveRegex.FindAllString("adam[23]", -1)) | |
fmt.Println(cveRegex.FindAllString("eve[7]", -1)) | |
fmt.Println(cveRegex.FindAllString("snakey", -1)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment