sastbox_sdk 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sastbox-sdk/codebase.rb +1 -2
- data/lib/sastbox-sdk/cwe_detector.rb +4 -6
- data/lib/sastbox-sdk/opt_parser.rb +6 -6
- data/lib/sastbox-sdk/printer.rb +1 -3
- data/lib/sastbox-sdk/reporter_sarif.rb +3 -3
- data/lib/sastbox-sdk/runner.rb +0 -1
- data/lib/sastbox-sdk/scanner.rb +4 -4
- data/lib/sastbox-sdk/severity_calculator.rb +0 -3
- data/lib/sastbox-sdk/snippet.rb +3 -3
- data/spec/sastbox-sdk/codebase_spec.rb +0 -1
- data/spec/sastbox-sdk/cwe_constants_spec.rb +0 -1
- data/spec/sastbox-sdk/cwe_detector_spec.rb +0 -3
- data/spec/sastbox-sdk/opt_parser_spec.rb +1 -2
- data/spec/sastbox-sdk/printer_spec.rb +0 -1
- data/spec/sastbox-sdk/reporter_sarif_spec.rb +2 -2
- data/spec/sastbox-sdk/runner_spec.rb +4 -5
- data/spec/sastbox-sdk/scanner_spec.rb +5 -6
- data/spec/sastbox-sdk/severity_calculator_spec.rb +0 -3
- data/spec/sastbox-sdk/snippet_spec.rb +0 -1
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19cc1d63d7f0232726451fe4cbed6055e88e683e02f246700be8ab4e3aa30ded
|
4
|
+
data.tar.gz: 4403d75cabb70ee91a9b8fe599f9ef9aab343adbcdbd117c99c776414bed0d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b8f1ae8184edb46dfd75d919f61a2af12cdb95275247c968776e78d696d3615822a7ceb823b11e1c21feb017bafeff8064e370484ba0c231eac0a4cfbaf728b
|
7
|
+
data.tar.gz: 11afdd66315f6d79e217d828fa997c19e1a2730b2cde93e856f725bcdcb46fd9e4087e7c1b11544eac849d4545635739346c578b8ec33077b8d096f5b249bfba
|
data/lib/sastbox-sdk/codebase.rb
CHANGED
@@ -2,7 +2,6 @@ require 'set'
|
|
2
2
|
|
3
3
|
module SastBox
|
4
4
|
module Cwe
|
5
|
-
|
6
5
|
def cwe_found?(issue, patterns, cwe)
|
7
6
|
patterns.each do |pattern|
|
8
7
|
@alternative_titles.each do |title|
|
@@ -12,7 +11,7 @@ module SastBox
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
14
|
+
false
|
16
15
|
end
|
17
16
|
|
18
17
|
def detected_sql_injection?(issue)
|
@@ -185,8 +184,8 @@ module SastBox
|
|
185
184
|
|
186
185
|
@alternative_titles << @alternative_titles.first.split('_').join(' ')
|
187
186
|
@alternative_titles << @alternative_titles.first.split('-').join(' ')
|
188
|
-
@alternative_titles << @alternative_titles.first.gsub(
|
189
|
-
@alternative_titles << @alternative_titles.first.gsub(
|
187
|
+
@alternative_titles << @alternative_titles.first.gsub('hard coded', 'hard-coded')
|
188
|
+
@alternative_titles << @alternative_titles.first.gsub('hardcoded', 'hard-coded')
|
190
189
|
@alternative_titles
|
191
190
|
end
|
192
191
|
|
@@ -197,6 +196,5 @@ module SastBox
|
|
197
196
|
cwe_start_heuristics(issue)
|
198
197
|
end
|
199
198
|
end
|
200
|
-
|
201
199
|
end
|
202
|
-
end
|
200
|
+
end
|
@@ -5,12 +5,12 @@ module SastBox
|
|
5
5
|
module OptParser
|
6
6
|
def parse_opts(args)
|
7
7
|
@opts = OpenStruct.new
|
8
|
-
@opts.verbose
|
9
|
-
@opts.info
|
10
|
-
@opts.color
|
11
|
-
@opts.diff_hashes
|
12
|
-
@opts.diff_quick
|
13
|
-
@opts.timeout
|
8
|
+
@opts.verbose = false
|
9
|
+
@opts.info = false
|
10
|
+
@opts.color = true
|
11
|
+
@opts.diff_hashes = []
|
12
|
+
@opts.diff_quick = false
|
13
|
+
@opts.timeout = 200 * 60
|
14
14
|
|
15
15
|
opt_parser = OptionParser.new do |opts|
|
16
16
|
opts.on('-c', '--codebase=CODEBASE', 'Codebase to be scanned') do |codebase|
|
data/lib/sastbox-sdk/printer.rb
CHANGED
@@ -3,7 +3,6 @@ require 'digest'
|
|
3
3
|
module SastBox
|
4
4
|
module Reporter
|
5
5
|
module Sarif
|
6
|
-
|
7
6
|
def generate_sarif_report
|
8
7
|
new_sarif_log
|
9
8
|
@issues.each do |issue|
|
@@ -92,7 +91,7 @@ module SastBox
|
|
92
91
|
}
|
93
92
|
}],
|
94
93
|
partialFingerprints: {
|
95
|
-
hashIssueV1: issue[:hash_issue],
|
94
|
+
hashIssueV1: issue[:hash_issue],
|
96
95
|
hashIssueV2: issue[:hash_issue_v2],
|
97
96
|
snippetHashLine: snippet[:evidence_line][:hash],
|
98
97
|
snippetHashFull: snippet[:evidence_full][:hash]
|
@@ -101,11 +100,12 @@ module SastBox
|
|
101
100
|
cweId: issue[:cwe_id].to_i,
|
102
101
|
tags: issue[:tags],
|
103
102
|
issueSeverity: issue[:severity],
|
103
|
+
solution: issue[:solution]
|
104
104
|
}
|
105
105
|
}
|
106
|
+
|
106
107
|
sarif_result
|
107
108
|
end
|
108
|
-
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
data/lib/sastbox-sdk/runner.rb
CHANGED
data/lib/sastbox-sdk/scanner.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module SastBox
|
2
2
|
class Scanner
|
3
|
-
|
4
3
|
include SastBox::OptParser
|
5
4
|
include SastBox::Printer
|
6
5
|
include SastBox::Runner
|
@@ -79,7 +78,8 @@ module SastBox
|
|
79
78
|
def skip_issue?(issue)
|
80
79
|
return true if issue[:filename].include?('/.git/')
|
81
80
|
return true if issue[:snippet][:read_success] == false
|
82
|
-
|
81
|
+
|
82
|
+
false
|
83
83
|
end
|
84
84
|
|
85
85
|
def validate_opts
|
@@ -115,7 +115,7 @@ module SastBox
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def save_scan_output
|
118
|
-
File.open(@opts.output,
|
118
|
+
File.open(@opts.output, 'wb') { |file| file.write(generate_sarif_report) }
|
119
119
|
print_normal("Sarif result saved to #{@opts.output}", 1)
|
120
120
|
end
|
121
121
|
|
@@ -143,8 +143,8 @@ module SastBox
|
|
143
143
|
if File.exist?(filename)
|
144
144
|
content = parse_json_from_str(File.read(filename))
|
145
145
|
end
|
146
|
+
|
146
147
|
content
|
147
148
|
end
|
148
|
-
|
149
149
|
end
|
150
150
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module SastBox
|
2
2
|
module SeverityCalculator
|
3
|
-
|
4
3
|
def add_severity(issue)
|
5
4
|
accepted_levels = [:info, :low, :medium, :high, :critical]
|
6
5
|
|
@@ -13,7 +12,6 @@ module SastBox
|
|
13
12
|
else
|
14
13
|
issue[:severity] = attempt_to_determine_severity(issue)
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
18
16
|
|
19
17
|
def severity_pattern_found?(patterns, text)
|
@@ -51,7 +49,6 @@ module SastBox
|
|
51
49
|
|
52
50
|
info = []
|
53
51
|
|
54
|
-
|
55
52
|
if level == :undefined
|
56
53
|
level = :critical if severity_pattern_found?(critical, text)
|
57
54
|
end
|
data/lib/sastbox-sdk/snippet.rb
CHANGED
@@ -2,7 +2,6 @@ require 'digest'
|
|
2
2
|
|
3
3
|
module SastBox
|
4
4
|
module Snippet
|
5
|
-
|
6
5
|
def filename_relative(filename)
|
7
6
|
filename_path = File.expand_path(filename)
|
8
7
|
codebase_path = File.expand_path(@opts.codebase)
|
@@ -10,9 +9,10 @@ module SastBox
|
|
10
9
|
if filename_path.start_with?(codebase_path)
|
11
10
|
filename_path.sub!(codebase_path, '')
|
12
11
|
filename_path = filename_path[1..-1] if filename_path.start_with?('/')
|
13
|
-
|
12
|
+
|
13
|
+
filename_path
|
14
14
|
else
|
15
|
-
|
15
|
+
nil
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -16,7 +16,7 @@ RSpec.describe 'Opt_parser' do
|
|
16
16
|
|
17
17
|
describe 'parse_opts' do
|
18
18
|
context 'should parse all the provided options' do
|
19
|
-
subject { scanner.parse_opts([
|
19
|
+
subject { scanner.parse_opts(%w[-c codebase -o outputfile -v -t 2 -n]) }
|
20
20
|
|
21
21
|
it 'codebase - is expected to eq "codebase"' do
|
22
22
|
expect(subject.codebase).to eq 'codebase'
|
@@ -44,4 +44,3 @@ RSpec.describe 'Opt_parser' do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
@@ -29,7 +29,7 @@ RSpec.describe 'Reporter_sarif' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
before do
|
32
|
-
scanner.parse_opts([
|
32
|
+
scanner.parse_opts(%w[-c xxx])
|
33
33
|
|
34
34
|
scanner.add_issue(
|
35
35
|
title: 'title',
|
@@ -46,7 +46,7 @@ RSpec.describe 'Reporter_sarif' do
|
|
46
46
|
|
47
47
|
describe 'generate_sarif_report' do
|
48
48
|
context 'should generate valid SARIF' do
|
49
|
-
subject {scanner.generate_sarif_report
|
49
|
+
subject {scanner.generate_sarif_report }
|
50
50
|
|
51
51
|
it {expect(subject).to be_a(String)}
|
52
52
|
|
@@ -46,9 +46,9 @@ RSpec.describe 'Runner' do
|
|
46
46
|
subject { scanner.run_cmd(['uname']) }
|
47
47
|
|
48
48
|
it { expect(subject).to be_an(Array) }
|
49
|
-
it { expect(subject.length).to be(
|
49
|
+
it { expect(subject.length).to be(3) }
|
50
50
|
it { expect(subject[0]).to eq "Linux\n" }
|
51
|
-
it { expect(subject[1]).to eq(
|
51
|
+
it { expect(subject[1]).to eq("").or be_an(Process::Status) }
|
52
52
|
end
|
53
53
|
|
54
54
|
context 'should exit with an invalid command' do
|
@@ -70,9 +70,9 @@ RSpec.describe 'Runner' do
|
|
70
70
|
subject { scanner_timeout_60_sec.run_cmd_with_timeout(['uname']) }
|
71
71
|
|
72
72
|
it { expect(subject).to be_an(Array) }
|
73
|
-
it { expect(subject.length).to be(
|
73
|
+
it { expect(subject.length).to be(3) }
|
74
74
|
it { expect(subject[0]).to eq "Linux\n" }
|
75
|
-
it { expect(subject[1]).to eq(
|
75
|
+
it { expect(subject[1]).to eq("").or be_an(Process::Status) }
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'should fail when exceeded timeout' do
|
@@ -89,4 +89,3 @@ RSpec.describe 'Runner' do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
@@ -16,7 +16,7 @@ RSpec.describe 'Scanner' do
|
|
16
16
|
describe 'start_scan' do
|
17
17
|
context 'should raise name error for run method when correct options are provided' do
|
18
18
|
before do
|
19
|
-
scanner.parse_opts([
|
19
|
+
scanner.parse_opts(%w[-o xxx -c aaa])
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should raise name error for run method when correct options are provided" do
|
@@ -48,7 +48,7 @@ RSpec.describe 'Scanner' do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
before do
|
51
|
-
scanner.parse_opts([
|
51
|
+
scanner.parse_opts(%w[-o xxx -c aaa])
|
52
52
|
scanner.add_issue(issue)
|
53
53
|
end
|
54
54
|
|
@@ -69,7 +69,7 @@ RSpec.describe 'Scanner' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
before do
|
72
|
-
scanner.parse_opts([
|
72
|
+
scanner.parse_opts(%w[-o xxx -c aaa])
|
73
73
|
end
|
74
74
|
|
75
75
|
it do
|
@@ -145,14 +145,14 @@ RSpec.describe 'Scanner' do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
before do
|
148
|
-
scanner.parse_opts([
|
148
|
+
scanner.parse_opts(%w[-c /abc/def/ghi])
|
149
149
|
@status = scanner.add_issue(issue)
|
150
150
|
end
|
151
151
|
|
152
152
|
#it { expect(@status).to be scanner.issues }
|
153
153
|
it { expect(scanner.issues.length).to be 1}
|
154
154
|
it "hash_issue_v1" do
|
155
|
-
expect(scanner.issues.first[:hash_issue]).to eq '
|
155
|
+
expect(scanner.issues.first[:hash_issue]).to eq '4d89fbb4cc1e2beef276558ead0c4a66d1048668edda40b36efae7f8c6f30642'
|
156
156
|
end
|
157
157
|
|
158
158
|
it "hash_issue_v2" do
|
@@ -235,4 +235,3 @@ RSpec.describe 'Scanner' do
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
end
|
238
|
-
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sastbox_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conviso Engineering Team
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-16 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: colored
|
@@ -30,14 +29,14 @@ dependencies:
|
|
30
29
|
requirements:
|
31
30
|
- - '='
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
32
|
+
version: 2.9.1
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - '='
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
39
|
+
version: 2.9.1
|
41
40
|
description: SDK to construct SAST scanners
|
42
41
|
email: product-development@convisoappsec.com
|
43
42
|
executables: []
|
@@ -74,7 +73,6 @@ homepage: ''
|
|
74
73
|
licenses:
|
75
74
|
- MIT
|
76
75
|
metadata: {}
|
77
|
-
post_install_message:
|
78
76
|
rdoc_options: []
|
79
77
|
require_paths:
|
80
78
|
- lib
|
@@ -89,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
87
|
- !ruby/object:Gem::Version
|
90
88
|
version: '0'
|
91
89
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
90
|
+
rubygems_version: 3.6.2
|
94
91
|
specification_version: 4
|
95
92
|
summary: SastBox SDK
|
96
93
|
test_files: []
|