Skip to content
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

Allow for sub-string of affected code for whitelisting #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wongherlung
Copy link
Collaborator

@wongherlung wongherlung commented Jan 20, 2021

In the newer version of gosec (formerly known as gas), the affected code/line will now output the line numbers and the lines before and after the affected code/line. This complicates the process of whitelisting findings from gosec as our whitelist file requires the exact output code to be in the JSON.

For example, a whitelisted finding entry will now look like this:

{
        "details": "Potential file inclusion via variable",
        "file": "/src/test/testHelper.go",
        "code": "53: func LoadTestFixtureAsString(t *testing.T, filename string) string {\n54: \tfixture, err := ioutil.ReadFile(filepath.Join("test-fixtures", filename))\n55: \tif err != nil {\n",
        "reason": "Code is only used for testing"
}

The code has to be manually escaped in order to exactly match what was supplied by gosec.

Given that we'll most probably be doing away with this report filter in the future, an interim stop-gap measure will be to allow for the code in the whitelist file to be a substring of the supplied code from gosec. This way it is easier to match and whitelist a finding.

@wongherlung wongherlung self-assigned this Jan 20, 2021
@wongherlung wongherlung changed the title apAllow for sub-string of affect code for whitelisting Allow for sub-string of affect code for whitelisting Jan 20, 2021
@wongherlung wongherlung changed the title Allow for sub-string of affect code for whitelisting Allow for sub-string of affected code for whitelisting Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants