Skip to content

Commit

Permalink
add maybe status
Browse files Browse the repository at this point in the history
  • Loading branch information
1lann committed Dec 11, 2021
1 parent d07264b commit b70c36f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store

dist/
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ module github.com/1lann/log4shelldetect
go 1.17

require (
github.com/fatih/color v1.13.0 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/fatih/color v1.13.0
github.com/karrick/godirwalk v1.16.1
)

require (
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
Expand Down
21 changes: 17 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,28 @@ func checkJar(pathToFile string) {

var vulnClassFound = false
var patchedClassFound = false
var maybeClassFound = ""

for _, file := range rd.File {
if strings.HasSuffix(file.Name, "apache/logging/log4j/core/lookup/JndiLookup.class") {
if strings.HasSuffix(file.Name, "log4j/core/lookup/JndiLookup.class") {
vulnClassFound = true
}

if strings.HasSuffix(file.Name, "apache/logging/log4j/core/lookup/JndiRestrictedLookup.class") {
if strings.HasSuffix(file.Name, "lookup/JndiLookup.class") {
maybeClassFound = file.Name
}

if strings.HasSuffix(file.Name, "log4j/core/lookup/JndiRestrictedLookup.class") {
patchedClassFound = true
}
}

if !vulnClassFound {
printStatus(pathToFile, StatusOK, "")
if maybeClassFound != "" {
printStatus(pathToFile, StatusMaybe, maybeClassFound)
} else {
printStatus(pathToFile, StatusOK, "")
}
} else if patchedClassFound {
printStatus(pathToFile, StatusPatched, "")
} else {
Expand All @@ -115,6 +124,7 @@ const (
StatusOK = iota
StatusVulnerable
StatusPatched
StatusMaybe
StatusUnknown
)

Expand All @@ -123,7 +133,7 @@ func printStatus(fileName string, status int, desc string) {
defer printMutex.Unlock()

if *mode == "list" {
if status == StatusVulnerable {
if status == StatusVulnerable || status == StatusMaybe {
fmt.Println(fileName)
}

Expand All @@ -141,6 +151,9 @@ func printStatus(fileName string, status int, desc string) {
case StatusVulnerable:
c = color.New(color.FgRed)
c.Print("VULNRBL ")
case StatusMaybe:
c = color.New(color.FgRed)
c.Print("MAYBE ")
case StatusUnknown:
c = color.New(color.FgYellow)
c.Print("UNKNOWN ")
Expand Down

0 comments on commit b70c36f

Please sign in to comment.