Skip to content

Commit 57ac844

Browse files
authored
fix: ignore determination should rely on Status property and ensure IAW FF enabled (#330)
1 parent 3d44563 commit 57ac844

File tree

15 files changed

+1375
-58
lines changed

15 files changed

+1375
-58
lines changed

.gitleaksignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ d5da1e7b3eb6676acca2021e4f3da07b1ff0d9a6:pkg/app/app_test.go:jwt:97
1919
5a4b6d6a75be3cbfc5122dd7d6d4ead5142b6429:pkg/app/app_test.go:jwt:95
2020
internal/auth/oauth_test.go:jwt:29
2121
d5da1e7b3eb6676acca2021e4f3da07b1ff0d9a6:pkg/auth/oauth_test.go:jwt:30
22+
6e8e7f338974aaf63b5974ceb29b76a1ee7867b6:internal/presenters/testdata/with-ignores-with-status.json:generic-api-key:539
23+
6e8e7f338974aaf63b5974ceb29b76a1ee7867b6:internal/presenters/testdata/with-ignores-with-status.json:generic-api-key:159
24+
6e8e7f338974aaf63b5974ceb29b76a1ee7867b6:internal/presenters/testdata/with-ignores-with-status.json:generic-api-key:224
25+
6e8e7f338974aaf63b5974ceb29b76a1ee7867b6:internal/presenters/testdata/with-ignores-with-status.json:generic-api-key:474

internal/presenters/__snapshots__/presenter_local_finding_test.snap

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,61 @@ Open Issues
474474

475475

476476
---
477+
478+
[TestPresenterLocalFinding_IncludeIgnored_WithStatusProperty - 1]
479+
480+
Testing /path/to/project ...
481+
482+
Open Issues
483+
484+
✗ [LOW] Hardcoded Secret
485+
Path: test/service-tests/service-utils/knex.service-spec.ts, line 72
486+
Info: Avoid hardcoding values that are meant to be secret. Found a hardcoded string used in here.
487+
488+
✗ [LOW] Hardcoded Secret
489+
Path: test/service-tests/service-utils/knex.service-spec.ts, line 76
490+
Info: Avoid hardcoding values that are meant to be secret. Found a hardcoded string used in here.
491+
492+
✗ [MEDIUM] Cleartext Transmission of Sensitive Information
493+
Path: src/main.ts, line 59
494+
Info: http.createServer uses HTTP which is an insecure protocol and should not be used in code due to cleartext transmission of information. Data in cleartext in a communication channel can be sniffed by unauthorized actors. Consider using the https module instead.
495+
496+
✗ [HIGH] Hardcoded Secret
497+
Path: scripts/db/migrations/20230811153738_add_generated_grouping_columns_to_collections_table.ts, line 4
498+
Info: Avoid hardcoding values that are meant to be secret. Found a hardcoded string used in here.
499+
500+
─────────────────────────────────────────────────────
501+
502+
Ignored Issues
503+
504+
! [ IGNORED ] [MEDIUM] Cleartext Transmission of Sensitive Information
505+
Path: src/main.ts, line 58
506+
Info: http.createServer uses HTTP which is an insecure protocol and should not be used in code due to cleartext transmission of information. Data in cleartext in a communication channel can be sniffed by unauthorized actors. Consider using the https module instead.
507+
508+
Expiration: 15 days
509+
Category: wont-fix
510+
Ignored on: February 23, 2024
511+
Ignored by: Neil M
512+
Reason: False positive
513+
514+
515+
516+
💡 Tip
517+
518+
Ignores are currently managed in the Snyk Web UI.
519+
To edit or remove the ignore please go to: https://app.snyk.io/
520+
521+
522+
╭────────────────────────────────────────────────────╮
523+
Test Summary
524+
│ │
525+
Organization: test-org
526+
Test type: Static code analysis
527+
Project path: /path/to/project
528+
│ │
529+
Total issues: 5
530+
Ignored issues: 1 [ 0 HIGH 1 MEDIUM 0 LOW ] │
531+
Open issues: 4 [ 1 HIGH 1 MEDIUM 2 LOW ] │
532+
╰────────────────────────────────────────────────────╯
533+
534+
---

internal/presenters/funcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212

1313
"github.com/charmbracelet/lipgloss"
1414

15-
"github.com/snyk/go-application-framework/internal/utils/sarif"
1615
"github.com/snyk/go-application-framework/pkg/configuration"
1716
"github.com/snyk/go-application-framework/pkg/local_workflows/local_models"
1817
"github.com/snyk/go-application-framework/pkg/runtimeinfo"
18+
"github.com/snyk/go-application-framework/pkg/utils/sarif"
1919
)
2020

2121
func add(a, b int) int {

internal/presenters/presenter_local_finding_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import (
1616
"github.com/stretchr/testify/require"
1717

1818
"github.com/snyk/go-application-framework/internal/presenters"
19-
sarif_utils "github.com/snyk/go-application-framework/internal/utils/sarif"
2019
"github.com/snyk/go-application-framework/pkg/configuration"
2120
localworkflows "github.com/snyk/go-application-framework/pkg/local_workflows"
2221
"github.com/snyk/go-application-framework/pkg/local_workflows/local_models"
22+
sarif_utils "github.com/snyk/go-application-framework/pkg/utils/sarif"
2323
)
2424

2525
func sarifToLocalFinding(t *testing.T, filename string) (localFinding *local_models.LocalFinding, err error) {
@@ -231,6 +231,37 @@ func TestPresenterLocalFinding_IncludeIgnored(t *testing.T) {
231231
snaps.MatchSnapshot(t, result)
232232
}
233233

234+
func TestPresenterLocalFinding_IncludeIgnored_WithStatusProperty(t *testing.T) {
235+
input, err := sarifToLocalFinding(t, "testdata/with-ignores-with-status.json")
236+
require.Nil(t, err)
237+
238+
lipgloss.SetColorProfile(termenv.Ascii)
239+
config := configuration.NewInMemory()
240+
config.Set(configuration.ORGANIZATION_SLUG, "test-org")
241+
config.Set(configuration.FLAG_INCLUDE_IGNORES, true)
242+
writer := new(bytes.Buffer)
243+
244+
p := presenters.NewLocalFindingsRenderer(
245+
[]*local_models.LocalFinding{input},
246+
config,
247+
writer,
248+
)
249+
250+
err = p.RenderTemplate(presenters.DefaultTemplateFiles, presenters.DefaultMimeType)
251+
result := writer.String()
252+
253+
require.Nil(t, err)
254+
255+
require.Contains(t, result, "Ignored Issues")
256+
require.Contains(t, result, "[ IGNORED ] [MEDIUM]")
257+
require.Contains(t, result, "src/main.ts, line 58")
258+
require.Contains(t, result, "Ignores are currently managed in the Snyk Web UI.")
259+
require.NotContains(t, result, "Empty ignore issues state")
260+
require.NotContains(t, result, "To view ignored and open issues, use the --include-ignores option.pre")
261+
262+
snaps.MatchSnapshot(t, result)
263+
}
264+
234265
func TestPresenterLocalFinding_IncludeIgnoredEmpty(t *testing.T) {
235266
input, err := sarifToLocalFinding(t, "testdata/3-low-issues.json")
236267
require.Nil(t, err)

0 commit comments

Comments
 (0)