Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Mar 7, 2024
1 parent 794650a commit ddbcd3d
Show file tree
Hide file tree
Showing 109 changed files with 8,066 additions and 15,978 deletions.
2 changes: 1 addition & 1 deletion e2e/flags/.snapshots/TestOuputFlag
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[{"detector_type":"ruby","source":{"end_column_number":12,"end_line_number":1,"filename":"main.rb","full_filename":"","language":"Ruby","language_type":"programming","start_column_number":8,"start_line_number":1,"text":null},"type":"schema_classified","value":{"classification":{"decision":{"reason":"","state":""},"name":"info"},"field_name":"info","field_type":"","field_type_simple":"unknown","normalized_field_name":"info","normalized_object_name":"logger","object_name":"logger"}},{"detector_type":"ruby","source":{"end_column_number":36,"end_line_number":1,"filename":"main.rb","full_filename":"","language":"Ruby","language_type":"programming","start_column_number":31,"start_line_number":1,"text":null},"type":"schema_classified","value":{"classification":{"data_type":{"category":{"groups":{"172d90e3-cb9a-46b6-90e5-dd7169c3af54":{"name":"PII","uuid":"172d90e3-cb9a-46b6-90e5-dd7169c3af54"},"e1d3135b-3c0f-4b55-abce-19f27a26cbb3":{"name":"Personal Data","uuid":"e1d3135b-3c0f-4b55-abce-19f27a26cbb3"}},"name":"Contact","uuid":"cef587dd-76db-430b-9e18-7b031e1a193b"},"category_uuid":"cef587dd-76db-430b-9e18-7b031e1a193b","name":"Email Address","uuid":"22e24c62-82d3-4b72-827c-e261533331bd"},"decision":{"reason":"known_pattern","state":"valid"},"name":"email","subject_name":"User"},"field_name":"email","field_type":"","field_type_simple":"unknown","normalized_field_name":"email","normalized_object_name":"user","object_name":"user"}},{"filenames":["main.rb"],"type":"file_list"}]
[{"detector_type":"ruby","source":{"end_column_number":12,"end_line_number":1,"filename":"main.rb","full_filename":"","language":"Ruby","language_type":"programming","start_column_number":8,"start_line_number":1},"type":"schema_classified","value":{"classification":{"decision":{"reason":"","state":""},"name":"info"},"field_name":"info","field_type":"","field_type_simple":"unknown","normalized_field_name":"info","normalized_object_name":"logger","object_name":"logger"}},{"detector_type":"ruby","source":{"end_column_number":36,"end_line_number":1,"filename":"main.rb","full_filename":"","language":"Ruby","language_type":"programming","start_column_number":31,"start_line_number":1},"type":"schema_classified","value":{"classification":{"data_type":{"category":{"groups":{"172d90e3-cb9a-46b6-90e5-dd7169c3af54":{"name":"PII","uuid":"172d90e3-cb9a-46b6-90e5-dd7169c3af54"},"e1d3135b-3c0f-4b55-abce-19f27a26cbb3":{"name":"Personal Data","uuid":"e1d3135b-3c0f-4b55-abce-19f27a26cbb3"}},"name":"Contact","uuid":"cef587dd-76db-430b-9e18-7b031e1a193b"},"category_uuid":"cef587dd-76db-430b-9e18-7b031e1a193b","name":"Email Address","uuid":"22e24c62-82d3-4b72-827c-e261533331bd"},"decision":{"reason":"known_pattern","state":"valid"},"name":"email","subject_name":"User"},"field_name":"email","field_type":"","field_type_simple":"unknown","normalized_field_name":"email","normalized_object_name":"user","object_name":"user"}},{"filenames":["main.rb"],"type":"file_list"}]

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"source":"Bearer","version":"dev","findings":[{"cwe_ids":["42"],"id":"test_ruby_logger","title":"Ruby logger","description":"Ruby logger","documentation_url":"","line_number":1,"full_filename":"e2e/flags/testdata/simple/main.rb","filename":"main.rb","data_type":{"category_uuid":"cef587dd-76db-430b-9e18-7b031e1a193b","name":"Email Address"},"category_groups":["PII","Personal Data"],"source":{"start":1,"end":1,"column":{"start":26,"end":36}},"sink":{"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":"8240e1537878783bac845d1163c80555_0","code_extract":"logger.info(\"user info\", user.email)","severity":"high"}]}
{"source":"Bearer","version":"dev","findings":[{"cwe_ids":["42"],"id":"test_ruby_logger","title":"Ruby logger","description":"Ruby logger","documentation_url":"","line_number":1,"full_filename":"e2e/flags/testdata/simple/main.rb","filename":"main.rb","data_type":{"category_uuid":"cef587dd-76db-430b-9e18-7b031e1a193b","name":"Email Address"},"category_groups":["PII","Personal Data"],"source":{"start":1,"end":1,"column":{"start":26,"end":36}},"sink":{"start":1,"end":1,"column":{"start":1,"end":37},"content":""},"parent_line_number":1,"fingerprint":"fa5e03644738e4c17cbbd04a580506b1_0","old_fingerprint":"8240e1537878783bac845d1163c80555_0","code_extract":"logger.info(\"user info\", user.email)","severity":"high"}]}

--
Analyzing codebase
Expand Down
3 changes: 1 addition & 2 deletions e2e/rules/.snapshots/TestAuxilary-testdata-data-auxilary
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ low:
column:
start: 1
end: 44
content: client.event("user", "logged_in", {}, user)
content: ""
parent_line_number: 11
snippet: client.event("user", "logged_in", {}, user)
fingerprint: 68427732321c4df53052a341ac8da647_0
old_fingerprint: 4d54a4b735da21fbdcb2d2662977b033_0
code_extract: client.event("user", "logged_in", {}, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ low:
column:
start: 3
end: 7
content: sink
content: ""
parent_line_number: 7
snippet: sink
fingerprint: eb59f129d5424fb58e3bfcb5bfa83159_0
old_fingerprint: e94b7fee5e58e735f107aa1cb3cfb75b_0
code_extract: ' sink'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"source":"Bearer","version":"dev","findings":[{"cwe_ids":["319"],"id":"expected_rule","title":"","description":"","documentation_url":"","line_number":3,"full_filename":"e2e/rules/testdata/data/expected_rule/main.rb","filename":"main.rb","source":{"start":3,"end":3,"column":{"start":3,"end":7}},"sink":{"start":3,"end":3,"column":{"start":3,"end":7},"content":"sink"},"parent_line_number":3,"snippet":"sink","fingerprint":"c50ecec7e1fcfba6cce5fcfab129556c_0","old_fingerprint":"6630ae26e5210b1e43bb4c02426e6be7_0","code_extract":" sink","severity":"low"},{"cwe_ids":["319"],"id":"expected_rule","title":"","description":"","documentation_url":"","line_number":8,"full_filename":"e2e/rules/testdata/data/expected_rule/main.rb","filename":"main.rb","source":{"start":8,"end":8,"column":{"start":3,"end":7}},"sink":{"start":8,"end":8,"column":{"start":3,"end":7},"content":"sink"},"parent_line_number":8,"snippet":"sink","fingerprint":"c50ecec7e1fcfba6cce5fcfab129556c_1","old_fingerprint":"6630ae26e5210b1e43bb4c02426e6be7_1","code_extract":" sink","severity":"low"}],"expected_findings":[{"rule_id":"expected_rule","location":{"start":3,"end":3,"column":{"start":3,"end":7}}},{"rule_id":"expected_rule","location":{"start":8,"end":8,"column":{"start":3,"end":7}}}]}
{"source":"Bearer","version":"dev","findings":[{"cwe_ids":["319"],"id":"expected_rule","title":"","description":"","documentation_url":"","line_number":3,"full_filename":"e2e/rules/testdata/data/expected_rule/main.rb","filename":"main.rb","source":{"start":3,"end":3,"column":{"start":3,"end":7}},"sink":{"start":3,"end":3,"column":{"start":3,"end":7},"content":""},"parent_line_number":3,"fingerprint":"c50ecec7e1fcfba6cce5fcfab129556c_0","old_fingerprint":"6630ae26e5210b1e43bb4c02426e6be7_0","code_extract":" sink","severity":"low"},{"cwe_ids":["319"],"id":"expected_rule","title":"","description":"","documentation_url":"","line_number":8,"full_filename":"e2e/rules/testdata/data/expected_rule/main.rb","filename":"main.rb","source":{"start":8,"end":8,"column":{"start":3,"end":7}},"sink":{"start":8,"end":8,"column":{"start":3,"end":7},"content":""},"parent_line_number":8,"fingerprint":"c50ecec7e1fcfba6cce5fcfab129556c_1","old_fingerprint":"6630ae26e5210b1e43bb4c02426e6be7_1","code_extract":" sink","severity":"low"}],"expected_findings":[{"rule_id":"expected_rule","location":{"start":3,"end":3,"column":{"start":3,"end":7}}},{"rule_id":"expected_rule","location":{"start":8,"end":8,"column":{"start":3,"end":7}}}]}

--
Analyzing codebase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ high:
column:
start: 1
end: 6
content: x.foo
content: ""
parent_line_number: 1
snippet: x.foo
fingerprint: df1f6d9ee9f4ee60085d0046163b3701_0
old_fingerprint: 52f7dcd9f1ba09f3a9f8c1ad305c8a89_0
code_extract: x.foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,77 @@ warning:
## Resources
- [Ruby on Rails Active Record encryption](https://guides.rubyonrails.org/active_record_encryption.html)
documentation_url: ""
line_number: 4
line_number: 3
full_filename: e2e/rules/testdata/data/ruby_rails_default_encryption_schema_rb/db/schema.rb
filename: db/schema.rb
category_groups:
- PII
- Personal Data
source:
location:
start: 4
end: 4
start: 3
end: 3
column:
start: 14
end: 20
end: 21
sink:
location:
start: 2
end: 8
column:
start: 3
end: 6
content: |-
create_table "users", force: :cascade do |t|
t.string "email", null: false
t.string "name"
t.string "encrypted_password", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
content: ""
parent_line_number: 2
snippet: |-
create_table "users", force: :cascade do |t|
fingerprint: a6e77c6d42db8f03ffbe5acae290f72c_0
old_fingerprint: 4b6d6e98ae7d9908efdf9a7984c7db05_0
code_extract: |4-
create_table "users", force: :cascade do |t|
t.string "email", null: false
t.string "name"
t.string "encrypted_password", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
fingerprint: a6e77c6d42db8f03ffbe5acae290f72c_0
old_fingerprint: 4b6d6e98ae7d9908efdf9a7984c7db05_0
- rule:
cwe_ids:
- "312"
id: ruby_rails_default_encryption
title: Missing application-level encryption of sensitive data detected.
description: |
## Description
Application-level encryption greatly reduces the risk of a data breach or data leak by making data unreadable. This rule checks if sensitive data types found in records are encrypted.

## Remediations
Whenever storing sensitive data to a datastore, make sure to encrypt the entire record, or the field itself.

## Resources
- [Ruby on Rails Active Record encryption](https://guides.rubyonrails.org/active_record_encryption.html)
documentation_url: ""
line_number: 4
full_filename: e2e/rules/testdata/data/ruby_rails_default_encryption_schema_rb/db/schema.rb
filename: db/schema.rb
category_groups:
- PII
- Personal Data
source:
location:
start: 4
end: 4
column:
start: 14
end: 20
sink:
location:
start: 2
end: 8
column:
start: 3
end: 6
content: ""
parent_line_number: 2
fingerprint: a6e77c6d42db8f03ffbe5acae290f72c_1
old_fingerprint: 4b6d6e98ae7d9908efdf9a7984c7db05_1
code_extract: |4-
create_table "users", force: :cascade do |t|
t.string "email", null: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,58 @@ warning:
column:
start: 1
end: 2
content: |-
CREATE TABLE public.users (
id bigint NOT NULL,
name character varying,
password character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
email character varying DEFAULT ''::character varying NOT NULL
)
content: ""
parent_line_number: 1
snippet: |-
fingerprint: e5e17cede9a731da09a639c9c78af007_0
old_fingerprint: 86b02d158d5ef7e6b68f6979f4f789aa_0
code_extract: |-
CREATE TABLE public.users (
id bigint NOT NULL,
name character varying,
password character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
email character varying DEFAULT ''::character varying NOT NULL
)
fingerprint: e5e17cede9a731da09a639c9c78af007_0
old_fingerprint: 86b02d158d5ef7e6b68f6979f4f789aa_0
);
- rule:
cwe_ids:
- "312"
id: ruby_rails_default_encryption
title: Missing application-level encryption of sensitive data detected.
description: |
## Description
Application-level encryption greatly reduces the risk of a data breach or data leak by making data unreadable. This rule checks if sensitive data types found in records are encrypted.

## Remediations
Whenever storing sensitive data to a datastore, make sure to encrypt the entire record, or the field itself.

## Resources
- [Ruby on Rails Active Record encryption](https://guides.rubyonrails.org/active_record_encryption.html)
documentation_url: ""
line_number: 7
full_filename: e2e/rules/testdata/data/ruby_rails_default_encryption_structure_sql/db/structure.sql
filename: db/structure.sql
category_groups:
- PII
- Personal Data
source:
location:
start: 7
end: 7
column:
start: 3
end: 8
sink:
location:
start: 1
end: 8
column:
start: 1
end: 2
content: ""
parent_line_number: 1
fingerprint: e5e17cede9a731da09a639c9c78af007_1
old_fingerprint: 86b02d158d5ef7e6b68f6979f4f789aa_1
code_extract: |-
CREATE TABLE public.users (
id bigint NOT NULL,
Expand Down
6 changes: 2 additions & 4 deletions e2e/rules/.snapshots/TestSanitizer-testdata-data-sanitizer
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ high:
column:
start: 1
end: 24
content: log("abc" + user.email)
content: ""
parent_line_number: 4
snippet: log("abc" + user.email)
fingerprint: 6c505050fabde2c4ed17380d19fab254_0
old_fingerprint: d2e829ba86a33c5a52844641617ad8a7_0
code_extract: log("abc" + user.email)
Expand Down Expand Up @@ -65,9 +64,8 @@ high:
column:
start: 1
end: 15
content: log("abc" + x)
content: ""
parent_line_number: 5
snippet: log("abc" + x)
fingerprint: 6c505050fabde2c4ed17380d19fab254_1
old_fingerprint: d2e829ba86a33c5a52844641617ad8a7_1
code_extract: log("abc" + x)
Expand Down
3 changes: 1 addition & 2 deletions e2e/rules/.snapshots/TestSecrets-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ high:
column:
start: 24
end: 60
content: ' @private_key ||= ''-----BEGIN PGP PRIVATE KEY BLOCK-----asdf-----END PGP PRIVATE KEY BLOCK-----'''
content: ""
parent_line_number: 3
snippet: ' @private_key ||= ''-----BEGIN PGP PRIVATE KEY BLOCK-----asdf-----END PGP PRIVATE KEY BLOCK-----'''
fingerprint: d0914f16c16550b40063c4f3fb14839e_0
old_fingerprint: 47146043fab58ba5fc86fd0c716b20d8_0
detailed_context: PGP private key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ low:
column:
start: 5
end: 29
content: config.force_ssl = false
content: ""
parent_line_number: 7
snippet: config.force_ssl = false
fingerprint: 52ee98cc601d1c1bd772ff548ee32425_0
old_fingerprint: 28ca51516a8b388cb7065c1f0df8b093_0
code_extract: ' config.force_ssl = false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
StartLineNumber: (*int)(12),
StartColumnNumber: (*int)(2),
EndLineNumber: (*int)(12),
EndColumnNumber: (*int)(22),
Text: (*string)((len=20) "orm.RegisterDataBase")
EndColumnNumber: (*int)(22)
},
Value: (beego.Database) {
Name: (string) (len=7) "default",
Expand All @@ -35,8 +34,7 @@
StartLineNumber: (*int)(11),
StartColumnNumber: (*int)(2),
EndLineNumber: (*int)(11),
EndColumnNumber: (*int)(25),
Text: (*string)((len=23) "ormlib.RegisterDataBase")
EndColumnNumber: (*int)(25)
},
Value: (beego.Database) {
Name: (string) (len=7) "default",
Expand Down
21 changes: 7 additions & 14 deletions internal/detectors/csharp/.snapshots/TestDetectorReportDataTypes
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
StartLineNumber: (*int)(6),
StartColumnNumber: (*int)(13),
EndLineNumber: (*int)(6),
EndColumnNumber: (*int)(22),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(22)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -41,8 +40,7 @@
StartLineNumber: (*int)(7),
StartColumnNumber: (*int)(13),
EndLineNumber: (*int)(7),
EndColumnNumber: (*int)(27),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(27)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -70,8 +68,7 @@
StartLineNumber: (*int)(8),
StartColumnNumber: (*int)(12),
EndLineNumber: (*int)(8),
EndColumnNumber: (*int)(30),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(30)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -99,8 +96,7 @@
StartLineNumber: (*int)(10),
StartColumnNumber: (*int)(19),
EndLineNumber: (*int)(10),
EndColumnNumber: (*int)(63),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(63)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -128,8 +124,7 @@
StartLineNumber: (*int)(12),
StartColumnNumber: (*int)(16),
EndLineNumber: (*int)(12),
EndColumnNumber: (*int)(19),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(19)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -157,8 +152,7 @@
StartLineNumber: (*int)(22),
StartColumnNumber: (*int)(17),
EndLineNumber: (*int)(22),
EndColumnNumber: (*int)(21),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(21)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down Expand Up @@ -186,8 +180,7 @@
StartLineNumber: (*int)(25),
StartColumnNumber: (*int)(26),
EndLineNumber: (*int)(25),
EndColumnNumber: (*int)(37),
Text: (*string)(<nil>)
EndColumnNumber: (*int)(37)
},
Value: (schema.Schema) {
ObjectName: (string) (len=8) "Customer",
Expand Down
Loading

0 comments on commit ddbcd3d

Please sign in to comment.