-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make cache work again after diff fixes (#1385)
- Loading branch information
Showing
6 changed files
with
141 additions
and
34 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
critical: | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: test_ruby_logger | ||
title: Ruby logger | ||
description: Ruby logger | ||
documentation_url: "" | ||
line_number: 1 | ||
full_filename: e2e/testdata/logger/main.rb | ||
filename: main.rb | ||
data_type: | ||
category_uuid: cef587dd-76db-430b-9e18-7b031e1a193b | ||
name: Email Address | ||
category_groups: | ||
- PII | ||
- Personal Data | ||
source: | ||
location: | ||
start: 1 | ||
end: 1 | ||
column: | ||
start: 26 | ||
end: 36 | ||
sink: | ||
location: | ||
start: 1 | ||
end: 1 | ||
column: | ||
start: 1 | ||
end: 37 | ||
content: logger.info("user info", user.email) | ||
parent_line_number: 1 | ||
snippet: logger.info("user info", user.email) | ||
fingerprint: fa5e03644738e4c17cbbd04a580506b1_0 | ||
old_fingerprint: 16c8aedf4ee6fe1f129aec2a9c14310c_0 | ||
code_extract: logger.info("user info", user.email) | ||
|
||
|
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,49 @@ | ||
package e2e_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bearer/bearer/e2e/internal/testhelper" | ||
"github.com/bradleyjkemp/cupaloy" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCache(t *testing.T) { | ||
arguments := []string{ | ||
"scan", | ||
"e2e/testdata/logger", | ||
"--format", "yaml", | ||
"--disable-version-check", | ||
"--disable-default-rules", | ||
"--external-rule-dir", "e2e/testdata/rules", | ||
"--exit-code=0", | ||
} | ||
|
||
noCacheStdOut, noCacheStdErr := testhelper.ExecuteTest( | ||
testhelper.NewTestCase( | ||
"no_cache", | ||
arguments, | ||
testhelper.TestCaseOptions{ | ||
DisplayStdErr: true, | ||
}, | ||
), | ||
t, | ||
) | ||
|
||
withCacheStdOut, withCacheStdErr := testhelper.ExecuteTest( | ||
testhelper.NewTestCase( | ||
"with_cache", | ||
arguments, | ||
testhelper.TestCaseOptions{ | ||
DisplayStdErr: true, | ||
IgnoreForce: true, | ||
}, | ||
), | ||
t, | ||
) | ||
|
||
assert.NotContains(t, noCacheStdErr, "Cached data used") | ||
assert.Contains(t, withCacheStdErr, "Cached data used") | ||
assert.Equal(t, noCacheStdOut, withCacheStdOut) | ||
cupaloy.SnapshotT(t, withCacheStdOut) | ||
} |
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 @@ | ||
logger.info("user info", user.email) |
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,15 @@ | ||
patterns: | ||
- pattern: logger.$<_>($<...>$<DATA_TYPE>$<...>) | ||
filters: | ||
- variable: DATA_TYPE | ||
detection: datatype | ||
scope: result | ||
languages: | ||
- ruby | ||
severity: high | ||
metadata: | ||
description: Ruby logger | ||
remediation_message: Ruby logger | ||
cwe_id: | ||
- 42 | ||
id: test_ruby_logger |
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