Skip to content

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.

3 participants