github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/misc/eol/main.go (about) 1 package main 2 3 import ( 4 "bufio" 5 "fmt" 6 "os" 7 "strings" 8 "time" 9 ) 10 11 // This script displays EOL dates 12 func main() { 13 fmt.Println("Debian") 14 debianEOL() 15 16 fmt.Println("\nUbuntu") 17 ubuntuEOL() 18 } 19 20 func debianEOL() { 21 f, err := os.Open("data/debian.csv") 22 if err != nil { 23 panic(err) 24 } 25 defer f.Close() 26 27 scanner := bufio.NewScanner(f) 28 for scanner.Scan() { 29 line := scanner.Text() 30 fields := strings.Split(line, ",") 31 32 if len(fields) < 6 && fields[0] != "" { 33 fmt.Printf("\"%s\": time.Date(3000, 1, 1, 23, 59, 59, 0, time.UTC),\n", fields[0]) 34 } else if len(fields) == 6 { 35 eol, _ := time.Parse("2006-1-2", fields[5]) // nolint: errcheck 36 fmt.Printf("\"%s\": time.Date(%d, %d, %d, 23, 59, 59, 0, time.UTC),\n", fields[0], eol.Year(), eol.Month(), eol.Day()) 37 } 38 } 39 } 40 41 func ubuntuEOL() { 42 f, err := os.Open("data/ubuntu.csv") 43 if err != nil { 44 panic(err) 45 } 46 defer f.Close() 47 48 scanner := bufio.NewScanner(f) 49 for scanner.Scan() { 50 line := scanner.Text() 51 fields := strings.Split(line, ",") 52 eol, _ := time.Parse("2006-1-2", fields[len(fields)-1]) // nolint: errcheck 53 fmt.Printf("\"%s\": time.Date(%d, %d, %d, 23, 59, 59, 0, time.UTC),\n", strings.Fields(fields[0])[0], eol.Year(), eol.Month(), eol.Day()) 54 } 55 }