-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove ellipsis support from Ruby (#176)
* refactor: remove ellipsis from ruby * test: add coverage for ruby logger and csv custom detectors
- Loading branch information
Showing
9 changed files
with
178 additions
and
15 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
integration/custom_detectors/.snapshots/TestCustomDetectors-detect_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
data_types: | ||
- name: Email Address | ||
detectors: | ||
- name: detect_ruby_logger | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 3 | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 3 | ||
- name: Physical Address | ||
detectors: | ||
- name: detect_ruby_logger | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 4 | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 4 | ||
risks: | ||
- detector_id: detect_ruby_logger | ||
data_types: | ||
- name: Email Address | ||
stored: false | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 3 | ||
- name: Physical Address | ||
stored: false | ||
locations: | ||
- filename: testdata/ruby/detect_ruby_logger.rb | ||
line_number: 4 | ||
components: [] | ||
|
||
|
||
-- | ||
|
84 changes: 84 additions & 0 deletions
84
integration/custom_detectors/.snapshots/TestCustomDetectors-ruby_file_detection
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,84 @@ | ||
data_types: | ||
- name: Email Address | ||
detectors: | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 5 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 12 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: ruby_file_detection | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 5 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 12 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: Emails | ||
detectors: | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 14 | ||
- name: Firstname | ||
detectors: | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 6 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: ruby_file_detection | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 6 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: Lastname | ||
detectors: | ||
- name: ruby | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 7 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: ruby_file_detection | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 7 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
risks: | ||
- detector_id: ruby_file_detection | ||
data_types: | ||
- name: Email Address | ||
stored: false | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 5 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 12 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: Firstname | ||
stored: false | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 6 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
- name: Lastname | ||
stored: false | ||
locations: | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 7 | ||
- filename: testdata/ruby/ruby_file_detection.rb | ||
line_number: 16 | ||
components: [] | ||
|
||
|
||
-- | ||
|
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,24 @@ | ||
package integration_test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/bearer/curio/integration/internal/testhelper" | ||
) | ||
|
||
func newScanTest(language, name, filename string) testhelper.TestCase { | ||
arguments := []string{"scan", filepath.Join("testdata", language, filename), "--report=dataflow", "--format=yaml"} | ||
options := testhelper.TestCaseOptions{StartWorker: true} | ||
|
||
return testhelper.NewTestCase(name, arguments, options) | ||
} | ||
|
||
func TestCustomDetectors(t *testing.T) { | ||
tests := []testhelper.TestCase{ | ||
newScanTest("ruby", "detect_ruby_logger", "detect_ruby_logger.rb"), | ||
newScanTest("ruby", "ruby_file_detection", "ruby_file_detection.rb"), | ||
} | ||
|
||
testhelper.RunTests(t, tests) | ||
} |
5 changes: 5 additions & 0 deletions
5
integration/custom_detectors/testdata/ruby/detect_ruby_logger.rb
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,5 @@ | ||
logger.info( | ||
"user info are:", | ||
user.email, | ||
user.address | ||
) |
18 changes: 18 additions & 0 deletions
18
integration/custom_detectors/testdata/ruby/ruby_file_detection.rb
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,18 @@ | ||
CSV.open("path/to/user.csv", "wb") do |csv| | ||
csv << ["email", "first_name", "last_name"] | ||
users.each do |user| | ||
csv << [ | ||
user.email, | ||
user.first_name, | ||
user.last_name | ||
] | ||
end | ||
end | ||
|
||
File.open("users.log", "w") { |f| f.write "#{Time.now} - User #{user.email} logged in\n" } | ||
|
||
File.open(user.emails, "users.csv", "w") do |f| | ||
users.each do |user| | ||
f.write "#{user.email},#{user.first_name},#{user.last_name}" | ||
end | ||
end |
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
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