Skip to content

Commit

Permalink
Cleanup variables
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 679118683
  • Loading branch information
vpasdf authored and copybara-github committed Sep 26, 2024
1 parent ef26272 commit 808b657
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
7 changes: 3 additions & 4 deletions detector/cve/cve202011978/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ func findairflowVersions(ix *inventoryindex.InventoryIndex) (string, *extractor.

// Scan checks for the presence of the airflow CVE-2020-11978 vulnerability on the filesystem.
func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *inventoryindex.InventoryIndex) ([]*detector.Finding, error) {
isVulnVersion := false

airflowVersion, inventory, affectedVersions := findairflowVersions(ix)
if airflowVersion == "" {
log.Infof("No airflow version found")
return nil, nil
}

isVulnVersion := false
for _, r := range affectedVersions {
if strings.Contains(airflowVersion, r) {
isVulnVersion = true
Expand Down Expand Up @@ -233,7 +233,6 @@ func CheckAccessibility(airflowIP string, airflowServerPort int) bool {
// CheckForBashTask checks if the airflow server has a bash task.
func CheckForBashTask(airflowIP string, airflowServerPort int) bool {
target := fmt.Sprintf("http://%s:%d/api/experimental/dags/example_trigger_target_dag/tasks/bash_task", airflowIP, airflowServerPort)
BashTaskPresence := false

client := &http.Client{Timeout: defaultTimeout}
resp, err := client.Get(target)
Expand All @@ -243,7 +242,7 @@ func CheckForBashTask(airflowIP string, airflowServerPort int) bool {
}
defer resp.Body.Close()

BashTaskPresence = resp.StatusCode == 200
BashTaskPresence := resp.StatusCode == 200
if !BashTaskPresence {
return false
}
Expand Down
9 changes: 2 additions & 7 deletions detector/cve/cve202016846/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ func findSaltVersions(ix *inventoryindex.InventoryIndex) (string, *extractor.Inv

// Scan checks for the presence of the Salt CVE-2020-16846 vulnerability on the filesystem.
func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *inventoryindex.InventoryIndex) ([]*detector.Finding, error) {
cherrypyPresence := false
exploitReturn := false

saltVersion, inventory, affectedVersions := findSaltVersions(ix)
if saltVersion == "" {
log.Infof("No Salt version found")
Expand All @@ -143,14 +140,12 @@ func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *in

log.Infof("Found Potentially vulnerable Salt version %v", saltVersion)

cherrypyPresence = CheckForCherrypy(saltServerIP, saltServerPort)
if !cherrypyPresence {
if !CheckForCherrypy(saltServerIP, saltServerPort) {
log.Infof("Cherry py not found. Version %q not vulnerable", saltVersion)
return nil, nil
}

exploitReturn = ExploitSalt(ctx, saltServerIP, saltServerPort)
if !exploitReturn {
if !ExploitSalt(ctx, saltServerIP, saltServerPort) {
log.Infof("Version %q not vulnerable", saltVersion)
return nil, nil
}
Expand Down
3 changes: 1 addition & 2 deletions detector/cve/cve20242912/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ func fileExists(filesys scalibrfs.FS, path string) bool {

// Scan checks for the presence of the BentoML CVE-2024-2912 vulnerability on the filesystem.
func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *inventoryindex.InventoryIndex) ([]*detector.Finding, error) {
isVulnVersion := false

bentomlVersion, inventory, fixedVersion := findBentomlVersions(ix)
if bentomlVersion == "" {
log.Infof("No BentoML version found")
Expand All @@ -176,6 +174,7 @@ func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *in
}

// Check if the installed version is lower than the fixed.
isVulnVersion := false
if bv[0] < fbv[0] {
isVulnVersion = true
} else if bv[0] == fbv[0] && bv[1] < fbv[1] {
Expand Down

0 comments on commit 808b657

Please sign in to comment.