-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Infer
as a new Security Test
#542
Open
thepabloaguilar
wants to merge
4
commits into
globocom:master
Choose a base branch
from
thepabloaguilar:issue-511
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af07292
Creates `infer` deployment files
thepabloaguilar c66a339
Modifies `client` to print out the Infer output
thepabloaguilar 4f5730e
Modifies `cli` to use `huskyci/infer` for Java projects
thepabloaguilar b7e585f
Modifies `api` to run Infer tests
thepabloaguilar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2021 Globo.com authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package securitytest | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/globocom/huskyCI/api/log" | ||
"github.com/globocom/huskyCI/api/types" | ||
) | ||
|
||
// InferOutput holds all data from Infer output. | ||
type InferOutput []InferResult | ||
|
||
// InferResult holds the detailed information from Infer output. | ||
type InferResult struct { | ||
Type string `json:"bug_type"` | ||
Message string `json:"qualifier"` | ||
File string `json:"file"` | ||
Line string `json:"line"` | ||
Severity string `json:"severity"` | ||
Title string `json:"bug_type_hum"` | ||
} | ||
|
||
func analyzeInfer(scanInfo *SecTestScanInfo) error { | ||
var inferOutput InferOutput | ||
|
||
if err := json.Unmarshal([]byte(scanInfo.Container.COutput), &inferOutput); err != nil { | ||
log.Error("analyzeInfer", "INFER", 1041, scanInfo.Container.COutput, err) | ||
scanInfo.ErrorFound = err | ||
return err | ||
} | ||
scanInfo.FinalOutput = inferOutput | ||
|
||
// if len is equal to zero no issues were found | ||
if len(inferOutput) == 0 { | ||
scanInfo.prepareContainerAfterScan() | ||
return nil | ||
} | ||
|
||
scanInfo.prepareInferVulns() | ||
scanInfo.prepareContainerAfterScan() | ||
return nil | ||
} | ||
|
||
func (inferScan *SecTestScanInfo) prepareInferVulns() { | ||
huskyCIInferResults := types.HuskyCISecurityTestOutput{} | ||
inferOutput := inferScan.FinalOutput.(InferOutput) | ||
|
||
for _, result := range inferOutput { | ||
inferVuln := types.HuskyCIVulnerability{ | ||
Language: "Java", | ||
SecurityTool: "Infer", | ||
Severity: result.Severity, | ||
File: result.File, | ||
Line: result.Line, | ||
Details: result.Message, | ||
Type: result.Type, | ||
Title: result.Title, | ||
} | ||
|
||
switch inferVuln.Severity { | ||
case "INFO": | ||
huskyCIInferResults.LowVulns = append(huskyCIInferResults.LowVulns, inferVuln) | ||
case "WARNING": | ||
huskyCIInferResults.MediumVulns = append(huskyCIInferResults.MediumVulns, inferVuln) | ||
case "ERROR": | ||
huskyCIInferResults.HighVulns = append(huskyCIInferResults.HighVulns, inferVuln) | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @thepabloaguilar ! I tried to run an analysis using infer and received a few errors. The
/etc/ssh
directory does not exist in this image, so I was getting an error when trying to write to a file inside it. Could you check if there is any command missing here?