dawnscanner 2.0.0.rc5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Changelog.md +11 -4
- data/README.md +50 -225
- data/VERSION +1 -1
- data/checksum/dawnscanner-2.0.0.gem.sha1 +1 -0
- data/checksum/dawnscanner-2.0.0.rc5.gem.sha1 +1 -0
- data/code_of_conduct.md +1 -1
- data/dawnscanner.gemspec +6 -8
- data/lib/dawn/cli/dawn_cli.rb +37 -11
- data/lib/dawn/core.rb +2 -4
- data/lib/dawn/engine.rb +9 -64
- data/lib/dawn/kb/basic_check.rb +9 -0
- data/lib/dawn/kb/unsafe_depedency_check.rb +3 -2
- data/lib/dawn/knowledge_base.rb +37 -0
- data/lib/dawn/version.rb +4 -4
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54d897767ce4e5a5e565205cafb15af72ae9bf92079718dfa416d8fcc4900cb
|
4
|
+
data.tar.gz: 17d4cba48fb33fb04c473b0cb9e9f85c1aa40c84f16a39c1df34332695e0435b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c689915e7a17e4db223a9ef587a3c70ab1e6f748d54dec0463da7cf728770a77f9a298995959befbe77f322771de1c1eefb5bdd9e6c27352c389e2789d4d05e9
|
7
|
+
data.tar.gz: be77801fb48251c860b2b07341927dbc704eb34f28951f082d0971aa23c96cdf90d70bff219b946e67facea7022948ac9aa3353e0a87a4441ab6f7ea5f7fa19f
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3
|
1
|
+
3.1
|
data/Changelog.md
CHANGED
@@ -5,16 +5,23 @@ It supports [Sinatra](http://www.sinatrarb.com),
|
|
5
5
|
[Padrino](http://www.padrinorb.com) and [Ruby on Rails](http://rubyonrails.org)
|
6
6
|
frameworks.
|
7
7
|
|
8
|
-
_latest update:
|
8
|
+
_latest update: thu 13 apr 2023, 16:54:52, CEST_
|
9
9
|
|
10
|
-
## Version 2.
|
10
|
+
## Version 2.1.0 (2023-04-13)
|
11
|
+
|
12
|
+
* BasicCheck: added an attribute do flag as vulnerable a dependency gem only if
|
13
|
+
it matches the name, overriding the version. It will be used in dawn kb list
|
14
|
+
command, when the user won't enter the version information.
|
15
|
+
* Added the "list" subcommand to "kb". It can be used to fetch from the
|
16
|
+
knowledge base all CVEs affecting a particular gem.
|
17
|
+
|
18
|
+
## Version 2.0.0 (2023-04-13)
|
11
19
|
|
12
20
|
* New knowledge base, YAML based and distributed separately from the ruby gem.
|
13
21
|
* New CLI based on Thor library. Please read README.md file to know how to
|
14
22
|
invoke dawn the right way or use the 'dawn help' command
|
15
23
|
* Added a new debug\_verbosely API for engines and checks
|
16
24
|
* Removed rake osvdb[name] and rake cve[name] tasks
|
17
|
-
* Adding telemetry
|
18
25
|
* Dawn::Utils include refactory. Now it's available application wide
|
19
26
|
* debug information refactory.
|
20
27
|
* engine class, apply_all method now accepts an optional parameter containing a
|
@@ -309,7 +316,7 @@ _latest update: mer 29 mar 2023, 18:32:56, CEST_
|
|
309
316
|
|
310
317
|
* Adding a check for OSVDB-108569: information disclosure in backup_checksum
|
311
318
|
gem (issue #69)
|
312
|
-
* Fix issue #74. Now
|
319
|
+
* Fix issue #74. Now BasicCheck has its own cve, osvdb attributes and a rake
|
313
320
|
task will perform a sanity check if those values have been initialized
|
314
321
|
* Fix issue #62 about codesake-dawn config filename
|
315
322
|
* Adding a check for CVE-2013-2105: HTML injection in show_in_browser rubygem
|
data/README.md
CHANGED
@@ -1,36 +1,15 @@
|
|
1
1
|
# Dawnscanner - The raising security scanner for ruby web applications
|
2
2
|
|
3
|
-
|
3
|
+
dawn is a source code scanner designed to review your web applications for
|
4
4
|
security issues.
|
5
5
|
|
6
|
-
|
6
|
+
The tool is able to scan web applications written in Ruby and it supports all
|
7
7
|
major MVC (Model View Controller) frameworks, out of the box:
|
8
8
|
|
9
9
|
* [Ruby on Rails](http://rubyonrails.org)
|
10
10
|
* [Sinatra](http://www.sinatrarb.com)
|
11
11
|
* [Padrino](http://www.padrinorb.com)
|
12
12
|
|
13
|
-
## Quick update from April, 2019
|
14
|
-
|
15
|
-
We just released version 2.0.0 release candidate 1 with a YAML powered revamped
|
16
|
-
knowledge base. Please note that dawnscanner will include a telemetry facility
|
17
|
-
sending a POST on https://dawnscanner.org/telemetry with an application id and
|
18
|
-
some information about version and knowledge base.
|
19
|
-
|
20
|
-
We won't now and ever collect your source code on our side.
|
21
|
-
|
22
|
-
## Quick update from November, 2018
|
23
|
-
|
24
|
-
As you can see dawnscanner is on hold since more then an year. Sorry for that.
|
25
|
-
It's life. I was overwhelmed by tons of stuff and I dedicated free time to
|
26
|
-
Offensive Security certifications. True to be told, I'm starting OSCE journey
|
27
|
-
really soon.
|
28
|
-
|
29
|
-
The dawnscanner project will be updated soon with new security checks and
|
30
|
-
kickstarted again.
|
31
|
-
|
32
|
-
Paolo
|
33
|
-
|
34
13
|
---
|
35
14
|
|
36
15
|
[![Gem Version](https://badge.fury.io/rb/dawnscanner.png)](http://badge.fury.io/rb/dawnscanner)
|
@@ -42,13 +21,13 @@ Paolo
|
|
42
21
|
|
43
22
|
---
|
44
23
|
|
45
|
-
|
46
|
-
|
47
|
-
|
24
|
+
dawn version 2.0 has 680+ security checks loaded in its knowledge base
|
25
|
+
which is weekly updated from the [National Vulnerability
|
26
|
+
Database](https://nvd.nist.gov/) by NIST.
|
48
27
|
|
49
|
-
##
|
28
|
+
## A brief "how it works"
|
50
29
|
|
51
|
-
When you run
|
30
|
+
When you run dawn on your code it parses your project Gemfile.lock
|
52
31
|
looking for the gems used and it tries to detect the ruby interpreter version
|
53
32
|
you are using or you declared in your ruby version management tool you like
|
54
33
|
most (RVM, rbenv, ...).
|
@@ -57,244 +36,94 @@ Then the tool tries to detect the MVC framework your web application uses and
|
|
57
36
|
it applies the security check accordingly. There checks designed to match rails
|
58
37
|
application or checks that are appliable to any ruby code.
|
59
38
|
|
60
|
-
|
39
|
+
dawn can also understand the code in your views and to backtrack
|
61
40
|
sinks to spot cross site scripting and sql injections introduced by the code
|
62
|
-
you actually wrote
|
63
|
-
development effort will be focused on
|
41
|
+
you actually wrote **(in the project roadmap this is the code most of the future
|
42
|
+
development effort will be focused on).**
|
64
43
|
|
65
|
-
|
44
|
+
dawn security scan result is a list of vulnerabilities with some
|
66
45
|
mitigation actions you want to follow in order to build a stronger web
|
67
46
|
application.
|
68
47
|
|
69
48
|
## Installation
|
70
49
|
|
71
|
-
You can install latest
|
50
|
+
You can install latest dawn version, fetching it from
|
72
51
|
[Rubygems](https://rubygems.org) by typing:
|
73
52
|
|
74
53
|
```
|
75
|
-
$ gem install dawnscanner
|
76
|
-
```
|
77
|
-
|
78
|
-
If you want to add dawn to your project Gemfile, you must add the following:
|
79
|
-
|
80
|
-
group :development do
|
81
|
-
gem 'dawnscanner', :require=>false
|
82
|
-
end
|
83
|
-
|
84
|
-
And then upgrade your bundle
|
85
|
-
|
86
|
-
$ bundle install
|
87
|
-
|
88
|
-
You may want to build it from source, so you have to check it out from github first:
|
89
|
-
|
90
|
-
$ git clone https://github.com/thesp0nge/dawnscanner.git
|
91
|
-
$ cd dawnscanner
|
92
|
-
$ bundle install
|
93
|
-
$ rake install
|
94
|
-
|
95
|
-
And the dawnscanner gem will be built in a pkg directory and then installed
|
96
|
-
on your system. Please note that you have to manage dependencies on your own
|
97
|
-
this way. It makes sense only if you want to hack the code or something like
|
98
|
-
that.
|
99
|
-
|
100
|
-
## Usage
|
101
|
-
|
102
|
-
You can start your code review with dawnscanner very easily. Simply tell the tool
|
103
|
-
where the project root directory.
|
104
|
-
|
105
|
-
Underlying MVC framework is autodetected by dawnscanner using target Gemfile.lock
|
106
|
-
file. If autodetect fails for some reason, the tool will complain about it and
|
107
|
-
you have to specify if it's a rails, sinatra or padrino web application by
|
108
|
-
hand.
|
109
|
-
|
110
|
-
Basic usage is to specify some optional command line option to fit best your
|
111
|
-
needs, and to specify the target directory where your code is stored.
|
112
|
-
|
113
|
-
```
|
114
|
-
$ dawn [options] target
|
54
|
+
$ gem install dawnscanner
|
115
55
|
```
|
116
56
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
```
|
121
|
-
$ dawn -h
|
122
|
-
Usage: dawn [options] target_directory
|
123
|
-
|
124
|
-
Examples:
|
125
|
-
$ dawn a_sinatra_webapp_directory
|
126
|
-
$ dawn -C the_rails_blog_engine
|
127
|
-
$ dawn -C --json a_sinatra_webapp_directory
|
128
|
-
$ dawn --ascii-tabular-report my_rails_blog_ecommerce
|
129
|
-
$ dawn --html -F my_report.html my_rails_blog_ecommerce
|
130
|
-
|
131
|
-
-G, --gem-lock force dawn to scan only for vulnerabilities affecting dependencies in Gemfile.lock (DEPRECATED)
|
132
|
-
-d, --dependencies force dawn to scan only for vulnerabilities affecting dependencies in Gemfile.lock
|
133
|
-
|
134
|
-
Reporting
|
135
|
-
|
136
|
-
-a, --ascii-tabular-report cause dawn to format findings using tables in ascii art (DEPRECATED)
|
137
|
-
-j, --json cause dawn to format findings using json
|
138
|
-
-K, --console cause dawn to format findings using plain ascii text
|
139
|
-
-C, --count-only dawn will only count vulnerabilities (useful for scripts)
|
140
|
-
-z, --exit-on-warn dawn will return number of found vulnerabilities as exit code
|
141
|
-
-F, --file filename tells dawn to write output to filename
|
142
|
-
-c, --config-file filename tells dawn to load configuration from filename
|
143
|
-
|
144
|
-
Disable security check family
|
145
|
-
|
146
|
-
--disable-cve-bulletins disable all CVE security checks
|
147
|
-
--disable-code-quality disable all code quality checks
|
148
|
-
--disable-code-style disable all code style checks
|
149
|
-
--disable-owasp-ror-cheatsheet disable all Owasp Ruby on Rails cheatsheet checks
|
150
|
-
--disable-owasp-top-10 disable all Owasp Top 10 checks
|
151
|
-
|
152
|
-
Flags useful to query Dawn
|
153
|
-
|
154
|
-
-S, --search-knowledge-base [check_name] search check_name in the knowledge base
|
155
|
-
--list-knowledge-base list knowledge-base content
|
156
|
-
--list-known-families list security check families contained in dawn's knowledge base
|
157
|
-
--list-known-framework list ruby MVC frameworks supported by dawn
|
158
|
-
--list-scan-registry list past scan informations stored in scan registry
|
159
|
-
|
160
|
-
Service flags
|
161
|
-
|
162
|
-
-D, --debug enters dawn debug mode
|
163
|
-
-V, --verbose the output will be more verbose
|
164
|
-
-v, --version show version information
|
165
|
-
-h, --help show this help
|
166
|
-
```
|
57
|
+
After that, you need to download the [knowledge
|
58
|
+
base](https://github.com/thesp0nge/dawn_knowledge_base/releases) from
|
59
|
+
Github and unpack the archive to ```$HOME/dawnscanner/kb``` directory.
|
167
60
|
|
168
|
-
|
169
|
-
|
170
|
-
To include dawnscanner in your rake task list, you simply have to put this line in
|
171
|
-
your ```Rakefile```
|
61
|
+
A typical kb directory layout is similar to this:
|
172
62
|
|
173
63
|
```
|
174
|
-
|
64
|
+
$ ll ~/dawnscanner/kb
|
65
|
+
total 56K
|
66
|
+
drwxr-xr-x 2 thesp0nge users 28K 29 mar 18.27 bulletin
|
67
|
+
drwxr-xr-x 2 thesp0nge users 72 7 lug 2021 generic_check
|
68
|
+
-rw-r--r-- 1 thesp0nge users 65 29 mar 17.06 kb.yaml
|
69
|
+
-rw-r--r-- 1 thesp0nge users 74 29 mar 17.06 kb.yaml.sig
|
70
|
+
drwxr-xr-x 2 thesp0nge users 4,0K 7 lug 2021 owasp_ror_cheatsheet
|
175
71
|
```
|
176
72
|
|
177
|
-
|
178
|
-
|
73
|
+
The knowledge base is structured this way:
|
74
|
+
* bulletin is the folder where all CVE downloaded from NIST are stored.
|
75
|
+
* generic_check is the folder with all custom checks for your code
|
76
|
+
* owasp_ror_cheatsheet is for the Owasp Ruby on Rails cheatsheet
|
77
|
+
recomendations
|
179
78
|
|
180
|
-
|
181
|
-
$ rake -T
|
182
|
-
...
|
183
|
-
rake dawn:run # Execute dawnscanner on the current directory
|
184
|
-
...
|
185
|
-
```
|
186
|
-
|
187
|
-
### Interacting with the knowledge base
|
188
|
-
|
189
|
-
You can dump all security checks in the knowledge base this way
|
190
|
-
|
191
|
-
```
|
192
|
-
$ dawn --list-knowledge-base
|
193
|
-
```
|
194
|
-
|
195
|
-
Useful in scripts, you can use ```--search-knowledge-base``` or ```-S``` with
|
196
|
-
as parameter the check name you want to see if it's implemented as a security
|
197
|
-
control or not.
|
198
|
-
|
199
|
-
```
|
200
|
-
$ dawn -S CVE-2013-6421
|
201
|
-
07:59:30 [*] dawn v1.1.0 is starting up
|
202
|
-
CVE-2013-6421 found in knowledgebase.
|
203
|
-
|
204
|
-
$ dawn -S this_test_does_not_exist
|
205
|
-
08:02:17 [*] dawn v1.1.0 is starting up
|
206
|
-
this_test_does_not_exist not found in knowledgebase
|
207
|
-
```
|
208
|
-
|
209
|
-
### dawnscanner security scan in action
|
79
|
+
## Usage
|
210
80
|
|
211
|
-
|
81
|
+
Starting from version 2.0, the tool uses subcommands to start specific tasks,
|
82
|
+
each of them with specific help messages.
|
212
83
|
|
213
|
-
|
214
|
-
[Sinatra 1.4.2 web application](https://github.com/thesp0nge/railsberry2013) wrote for a talk I
|
215
|
-
delivered in 2013 at [Railsberry conference](http://www.railsberry.com).
|
84
|
+
### Scanning a project
|
216
85
|
|
217
|
-
|
218
|
-
|
219
|
-
Sinatra (49 security checks, in version 1.0, especially designed for Ruby on
|
220
|
-
Rails) and it applies them.
|
86
|
+
The scan subcommand tells dawn to scan the specified target for security
|
87
|
+
issues.
|
221
88
|
|
222
89
|
```
|
223
|
-
$ dawn
|
224
|
-
18:40:27 [*] dawn v1.1.0 is starting up
|
225
|
-
18:40:27 [$] dawn: scanning /Users/thesp0nge/src/hacking/railsberry2013
|
226
|
-
18:40:27 [$] dawn: sinatra v1.4.2 detected
|
227
|
-
18:40:27 [$] dawn: applying all security checks
|
228
|
-
18:40:27 [$] dawn: 109 security checks applied - 0 security checks skipped
|
229
|
-
18:40:27 [$] dawn: 1 vulnerabilities found
|
230
|
-
18:40:27 [!] dawn: CVE-2013-1800 check failed
|
231
|
-
18:40:27 [$] dawn: Severity: high
|
232
|
-
18:40:27 [$] dawn: Priority: unknown
|
233
|
-
18:40:27 [$] dawn: Description: The crack gem 0.3.1 and earlier for Ruby does not properly restrict casts of string values, which might allow remote attackers to conduct object-injection attacks and execute arbitrary code, or cause a denial of service (memory and CPU consumption) by leveraging Action Pack support for (1) YAML type conversion or (2) Symbol type conversion, a similar vulnerability to CVE-2013-0156.
|
234
|
-
18:40:27 [$] dawn: Solution: Please use crack gem version 0.3.2 or above. Correct your gemfile
|
235
|
-
18:40:27 [$] dawn: Evidence:
|
236
|
-
18:40:27 [$] dawn: Vulnerable crack gem version found: 0.3.1
|
237
|
-
18:40:27 [*] dawn is leaving
|
90
|
+
$ dawn scan target
|
238
91
|
```
|
239
92
|
|
240
|
-
|
93
|
+
At the moment results are available in text format only and they are stored in
|
94
|
+
a directory named with the scan timestamp, under
|
95
|
+
$HOME/dawnscanner/results/target, where target is the name of the application
|
96
|
+
being analyzed.
|
241
97
|
|
242
|
-
|
243
|
-
it's likely to return a friendly _no vulnerabilities found_ message. Keep it up
|
244
|
-
working that way!
|
98
|
+
### Querying the knowledge base
|
245
99
|
|
246
|
-
|
247
|
-
scorecard quiz game about application security](http://scorecard.armoredcode.com).
|
248
|
-
Italian language only. Sorry.
|
100
|
+
Is it possible, with the kb subcommand, to query the knowledge base.
|
249
101
|
|
250
102
|
```
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
18:42:39 [*] dawn is leaving
|
103
|
+
dawn kb find # Searches the knowledge base for a given vulnerability
|
104
|
+
dawn kb help [COMMAND] # Describe subcommands or one specific subcommand
|
105
|
+
dawn kb lint # Checks knowledge base content for correcteness
|
106
|
+
dawn kb list gem_name[gem_version] # List all security issues affecting a gem passed as argument (the version string is optional).
|
107
|
+
dawn kb status # Checks the status of the knowledge base
|
108
|
+
dawn kb unpack # Unpacks security checks in KB library path
|
258
109
|
```
|
259
110
|
|
260
|
-
If you need a fancy HTML report about your scan, just ask it to dawnscanner
|
261
|
-
with the ```--html``` flag used with the ```--file``` since I wanto to save the
|
262
|
-
HTML to disk.
|
263
|
-
|
264
|
-
```
|
265
|
-
$ dawn /Users/thesp0nge/src/hacking/rt_first_app --html --file report.html
|
266
|
-
|
267
|
-
09:00:54 [*] dawn v1.1.0 is starting up
|
268
|
-
09:00:54 [*] dawn: report.html created (2952 bytes)
|
269
|
-
09:00:54 [*] dawn is leaving
|
270
|
-
```
|
271
|
-
|
272
|
-
---
|
273
|
-
|
274
111
|
## Useful links
|
275
112
|
|
276
|
-
Project homepage: [http://dawnscanner.org](http://dawnscanner.org)
|
277
|
-
|
278
113
|
Twitter profile: [@dawnscanner](https://twitter.com/dawnscanner)
|
279
|
-
|
280
114
|
Github repository: [https://github.com/thesp0nge/dawnscanner](https://github.com/thesp0nge/dawnscanner)
|
281
115
|
|
282
|
-
Mailing list: [https://groups.google.com/forum/#!forum/dawnscanner](https://groups.google.com/forum/#!forum/dawnscanner)
|
283
116
|
|
284
117
|
## Support us
|
285
118
|
|
286
119
|
Feedbacks are great and we really love to hear your voice.
|
287
120
|
|
288
|
-
If you're a proud
|
121
|
+
If you're a proud dawn user, if you find it useful, if you integrated
|
289
122
|
it in your release process and if you want to openly support the project you
|
290
123
|
can put your reference here. Just open an
|
291
124
|
[issue](https://github.com/thesp0nge/dawnscanner/issues/new) with a statement saying
|
292
125
|
how do you feel the tool and your company logo if any.
|
293
126
|
|
294
|
-
More easily you can drop an email to
|
295
|
-
[paolo@dawnscanner.org](mailto:paolo@dawnscanner.org) sending a statement about your
|
296
|
-
success story and I'll put on the website.
|
297
|
-
|
298
127
|
Thank you.
|
299
128
|
|
300
129
|
## Thanks to
|
@@ -310,7 +139,7 @@ Thank you.
|
|
310
139
|
|
311
140
|
## LICENSE
|
312
141
|
|
313
|
-
Copyright (c) 2013-
|
142
|
+
Copyright (c) 2013-2023 Paolo Perego <paolo@armoredcode.com>
|
314
143
|
|
315
144
|
MIT License
|
316
145
|
|
@@ -332,7 +161,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
332
161
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
333
162
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
334
163
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
data/VERSION
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
85ef0190d8b51e779c42122f673bb6dd495a8d9f
|
@@ -0,0 +1 @@
|
|
1
|
+
a3c19b2d55316c328e45c0f316216b56397f4ef3
|
data/code_of_conduct.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at paolo@
|
58
|
+
reported by contacting the project team at paolo@armoredcode.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/dawnscanner.gemspec
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'dawn/version'
|
2
|
+
require_relative 'lib/dawn/version'
|
5
3
|
|
6
4
|
Gem::Specification.new do |gem|
|
7
5
|
gem.name = "dawnscanner"
|
8
6
|
gem.version = Dawn::VERSION
|
9
7
|
gem.authors = ["Paolo Perego"]
|
10
|
-
gem.email = ["paolo@
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
13
|
-
gem.homepage = "https://dawnscanner
|
8
|
+
gem.email = ["paolo@armoredcode.com"]
|
9
|
+
gem.description = %q{dawn is a security source code scanner for ruby powered code. It is especially designed for web applications, but it works also with general purpose ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra; it provides more than 680 security checks with their own mitigation suggestion.}
|
10
|
+
gem.summary = %q{dawn is a security source code scanner for ruby powered code. It is crafted with love to make your sinatra, padrino and ruby on rails web applications secure.}
|
11
|
+
gem.homepage = "https://github.com/thesp0nge/dawnscanner"
|
14
12
|
gem.files = `git ls-files`.split($/)
|
15
13
|
gem.license = "MIT"
|
16
14
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
16
|
gem.require_paths = ["lib"]
|
19
17
|
|
20
|
-
gem.required_ruby_version = '>=
|
18
|
+
gem.required_ruby_version = '>= 3.0.0'
|
21
19
|
|
22
20
|
gem.add_dependency 'cvss'
|
23
21
|
gem.add_dependency 'haml'
|
data/lib/dawn/cli/dawn_cli.rb
CHANGED
@@ -6,21 +6,34 @@ module Dawn
|
|
6
6
|
# This class is responsible for the "dawn kb" command and related
|
7
7
|
# subcommands.
|
8
8
|
class Kb < Thor
|
9
|
-
package_name "
|
10
|
-
|
9
|
+
package_name "dawn"
|
10
|
+
class_option :verbose, :type=>:boolean
|
11
|
+
class_option :debug, :type=>:boolean
|
12
|
+
|
13
|
+
no_commands{
|
14
|
+
def init_globals
|
15
|
+
$debug = true if options[:debug]
|
16
|
+
$verbose = true if options[:verbose]
|
17
|
+
end
|
18
|
+
}
|
19
|
+
|
20
|
+
desc "find", "Searches the knowledge base for a given vulnerability"
|
11
21
|
def find(string)
|
22
|
+
init_globals
|
12
23
|
kb = Dawn::KnowledgeBase.instance
|
13
24
|
kb.find(string)
|
14
25
|
end
|
15
26
|
|
16
27
|
desc "lint", "Checks knowledge base content for correcteness"
|
17
28
|
def lint
|
29
|
+
init_globals
|
18
30
|
kb = Dawn::KnowledgeBase.instance
|
19
31
|
kb.load(true)
|
20
32
|
end
|
21
33
|
|
22
34
|
desc "unpack", "Unpacks security checks in KB library path"
|
23
35
|
def unpack
|
36
|
+
init_globals
|
24
37
|
$logger.helo APPNAME, Dawn::VERSION
|
25
38
|
kb = Dawn::KnowledgeBase.instance
|
26
39
|
kb.unpack
|
@@ -30,6 +43,7 @@ module Dawn
|
|
30
43
|
|
31
44
|
desc "status", "Checks the status of the knowledge base"
|
32
45
|
def status
|
46
|
+
init_globals
|
33
47
|
$logger.helo APPNAME, Dawn::VERSION
|
34
48
|
Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
|
35
49
|
kb = Dawn::KnowledgeBase.instance
|
@@ -44,10 +58,29 @@ module Dawn
|
|
44
58
|
$logger.bye
|
45
59
|
Kernel.exit(0)
|
46
60
|
end
|
61
|
+
|
62
|
+
desc "list gem_name[gem_version]", "List all security issues affecting a gem passed as argument (the version string is optional)."
|
63
|
+
def list(gem_name, gem_version=nil)
|
64
|
+
init_globals
|
65
|
+
to_check="#{gem_name}"
|
66
|
+
to_check += ":#{gem_version}" unless gem_version.nil?
|
67
|
+
|
68
|
+
Dawn::KnowledgeBase.enabled_checks=[:bulletin]
|
69
|
+
kb = Dawn::KnowledgeBase.instance
|
70
|
+
kb.load
|
71
|
+
if kb.security_checks.empty?
|
72
|
+
$logger.error(kb.error)
|
73
|
+
end
|
74
|
+
issues = kb.find_issues_by_gem(to_check)
|
75
|
+
|
76
|
+
issues.each do |issue|
|
77
|
+
puts "#{issue.name} "
|
78
|
+
end
|
79
|
+
end
|
47
80
|
end
|
48
81
|
|
49
82
|
class DawnCli < Thor
|
50
|
-
package_name "
|
83
|
+
package_name "dawn"
|
51
84
|
class_option :verbose, :type=>:boolean
|
52
85
|
class_option :debug, :type=>:boolean
|
53
86
|
|
@@ -90,14 +123,6 @@ module Dawn
|
|
90
123
|
|
91
124
|
debug_me($config)
|
92
125
|
|
93
|
-
$telemetry_url = $config[:telemetry][:endpoint] if $config[:telemetry][:enabled]
|
94
|
-
debug_me("telemetry url is " + $telemetry_url) unless @telemetry_url.nil?
|
95
|
-
|
96
|
-
$telemetry_id = $config[:telemetry][:id] if $config[:telemetry][:enabled]
|
97
|
-
debug_me("telemetry id is " + $telemetry_id) unless @telemetry_id.nil?
|
98
|
-
|
99
|
-
debug_me("telemetry is disabled in config file") unless $config[:telemetry][:enabled]
|
100
|
-
|
101
126
|
engine = Dawn::Core.detect_mvc(target) unless options[:gemfile]
|
102
127
|
engine = Dawn::GemfileLock.new(target) if options[:gemfile]
|
103
128
|
|
@@ -127,6 +152,7 @@ module Dawn
|
|
127
152
|
end
|
128
153
|
|
129
154
|
$logger.info("#{engine.count_vulnerabilities} issues found")
|
155
|
+
$logger.info("#{engine.checks.count} checks applied")
|
130
156
|
|
131
157
|
Dawn::Reporter.new({:engine=>engine, :apply_all_code=>ret}).report
|
132
158
|
$logger.bye
|
data/lib/dawn/core.rb
CHANGED
@@ -123,7 +123,7 @@ module Dawn
|
|
123
123
|
|
124
124
|
# If create_if_none flag is set to true, than I'll create a config file
|
125
125
|
# on the current directory with the default configuration.
|
126
|
-
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES
|
126
|
+
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES}
|
127
127
|
|
128
128
|
# Calculate the conf file path
|
129
129
|
conf_path = File.expand_path('~') +'/.'+conf_name
|
@@ -138,7 +138,7 @@ module Dawn
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def self.read_conf(file=nil)
|
141
|
-
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES
|
141
|
+
conf = {:verbose=>false, :output=>"tabular", :mvc=>"", :gemfile_scan=>false, :gemfile_name=>"", :filename=>nil, :debug=>false, :exit_on_warn => false, :enabled_checks=> Dawn::Kb::BasicCheck::ALLOWED_FAMILIES}
|
142
142
|
begin
|
143
143
|
debug_me("returning a default config") if file.nil? or ! File.exist?(file)
|
144
144
|
return conf if file.nil?
|
@@ -151,7 +151,6 @@ module Dawn
|
|
151
151
|
|
152
152
|
cf = YAML.load_file(file)
|
153
153
|
|
154
|
-
tm = cf[:telemetry]
|
155
154
|
cc = cf[:enabled_checks]
|
156
155
|
|
157
156
|
# TODO
|
@@ -160,7 +159,6 @@ module Dawn
|
|
160
159
|
conf[:debug] = cf["debug"] unless cf["debug"].nil?
|
161
160
|
conf[:output] = cf["output"] unless cf["output"].nil?
|
162
161
|
conf[:enabled_checks] = cc unless cc.nil?
|
163
|
-
conf[:telemetry] = tm unless tm.nil?
|
164
162
|
|
165
163
|
return conf
|
166
164
|
end
|
data/lib/dawn/engine.rb
CHANGED
@@ -270,8 +270,6 @@ module Dawn
|
|
270
270
|
# otherwise
|
271
271
|
def apply(name)
|
272
272
|
|
273
|
-
telemetry
|
274
|
-
|
275
273
|
# FIXME.20140325
|
276
274
|
# Now if no checks are loaded because knowledge base was not previously called, apply and apply_all proudly refuse to run.
|
277
275
|
# Reason is simple, load_knowledge_base now needs enabled check array
|
@@ -293,66 +291,13 @@ module Dawn
|
|
293
291
|
false
|
294
292
|
end
|
295
293
|
|
296
|
-
def have_a_telemetry_id?
|
297
|
-
debug_me ($telemetry_id != "" and ! $telemetry_id.nil?)
|
298
|
-
return ($telemetry_id != "" and ! $telemetry_id.nil?)
|
299
|
-
|
300
|
-
end
|
301
|
-
|
302
|
-
def get_a_telemetry_id
|
303
|
-
return "" if ($telemetry_url == "" or $telemetry_url.nil?)
|
304
|
-
debug_me("T: " + $telemetry_url)
|
305
|
-
|
306
|
-
url = URI.parse($telemetry_url+"/new")
|
307
|
-
res = Net::HTTP.get_response(url)
|
308
|
-
|
309
|
-
return "" unless res.code.to_i == 200
|
310
|
-
return JSON.parse(res.body)["uuid"]
|
311
|
-
end
|
312
|
-
|
313
|
-
def telemetry
|
314
|
-
unless $config[:telemetry][:enabled]
|
315
|
-
debug_me("telemetry is disabled")
|
316
|
-
return false
|
317
|
-
end
|
318
|
-
|
319
|
-
unless have_a_telemetry_id?
|
320
|
-
$telemetry_id = get_a_telemetry_id
|
321
|
-
$config[:telemetry][:id] = $telemetry_id
|
322
|
-
debug_me($config)
|
323
|
-
debug_me("saving config to " + $config_name)
|
324
|
-
File.open($config_name, 'w') { |f| f.write $config.to_yaml }
|
325
|
-
end
|
326
294
|
|
327
|
-
debug_me("Telemetry ID is: " + $telemetry_id)
|
328
|
-
|
329
|
-
uri=URI.parse($telemetry_url+"/"+$telemetry_id)
|
330
|
-
header = {'Content-Type': 'text/json'}
|
331
|
-
tele = { "kb_version" => Dawn::KnowledgeBase::VERSION ,
|
332
|
-
"ip" => Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address,
|
333
|
-
"message"=> Dawn::KnowledgeBase
|
334
|
-
}
|
335
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
336
|
-
request = Net::HTTP::Post.new(uri.request_uri, header)
|
337
|
-
request.body = tele.to_json
|
338
|
-
|
339
|
-
begin
|
340
|
-
response=http.request(request)
|
341
|
-
debug_me(response.inspect)
|
342
|
-
return true
|
343
|
-
rescue => e
|
344
|
-
$logger.error "telemetry: #{e.message}"
|
345
|
-
return false
|
346
|
-
end
|
347
|
-
end
|
348
295
|
|
349
296
|
def apply_all(checks_to_be_skipped=[])
|
350
297
|
@scan_start = Time.now
|
351
298
|
debug_me("I'm asked to skip those checks #{checks_to_be_skipped}")
|
352
299
|
debug_me("SCAN STARTED: #{@scan_start}")
|
353
300
|
|
354
|
-
telemetry
|
355
|
-
|
356
301
|
if @checks.nil?
|
357
302
|
$logger.error "you must load knowledge base before trying to apply security checks"
|
358
303
|
@scan_stop = Time.now
|
@@ -456,15 +401,15 @@ module Dawn
|
|
456
401
|
vc = nil
|
457
402
|
vc = check.vulnerable_checks if check.kind == Dawn::KnowledgeBase::COMBO_CHECK
|
458
403
|
|
459
|
-
@vulnerabilities << {:name=> check.name,
|
460
|
-
:severity=>check.severity,
|
461
|
-
:priority=>check.priority,
|
462
|
-
:kind=>check.check_family,
|
463
|
-
:message=>check.message,
|
464
|
-
:remediation=>check.remediation,
|
465
|
-
:evidences=>check.evidences,
|
466
|
-
:cve_link=>check.cve_link,
|
467
|
-
:cvss_score=>check.cvss_score,
|
404
|
+
@vulnerabilities << {:name=> check.name || "CVE-XXXX-YYYY",
|
405
|
+
:severity=>check.severity || "Unknown severity",
|
406
|
+
:priority=>check.priority || "Unknown priority",
|
407
|
+
:kind=>check.check_family || "Unknown kind",
|
408
|
+
:message=>check.message || "",
|
409
|
+
:remediation=>check.remediation || "",
|
410
|
+
:evidences=>check.evidences || [],
|
411
|
+
:cve_link=>check.cve_link || "No link",
|
412
|
+
:cvss_score=>check.cvss_score || "No score",
|
468
413
|
:vulnerable_checks=>vc}
|
469
414
|
|
470
415
|
end
|
data/lib/dawn/kb/basic_check.rb
CHANGED
@@ -78,6 +78,13 @@ module Dawn
|
|
78
78
|
# + :none
|
79
79
|
attr_accessor :priority
|
80
80
|
|
81
|
+
# Introduced in 2.1.0
|
82
|
+
# It allows a security check to be marked as positive (vulnerable), only
|
83
|
+
# if it matches the dependency gem name, ignoring the version.
|
84
|
+
#
|
85
|
+
# Only used in DEPENDENCY and UNSAFE_DEPENDENCY checks
|
86
|
+
attr_accessor :please_ignore_dep_version
|
87
|
+
|
81
88
|
def initialize(options={})
|
82
89
|
@applies = []
|
83
90
|
@ruby_version = ""
|
@@ -114,6 +121,8 @@ module Dawn
|
|
114
121
|
@priority = options[:priority] unless options[:priority].nil?
|
115
122
|
@check_family = options[:check_family] unless options[:check_family].nil?
|
116
123
|
|
124
|
+
@please_ignore_dep_version = false
|
125
|
+
|
117
126
|
# FIXME.20140325
|
118
127
|
#
|
119
128
|
# I don't want to manually fix 150+ ruby files to add something I can
|
@@ -31,8 +31,9 @@ module Dawn
|
|
31
31
|
@dependencies.each do |dep|
|
32
32
|
unless @vulnerable_version_array.nil? or @vulnerable_version_array.empty?
|
33
33
|
if dep[:name] == @vulnerable_version_array[0][:name]
|
34
|
-
return
|
35
|
-
return
|
34
|
+
return true if @please_ignore_dep_version
|
35
|
+
return false if @vulnerable_version_array[0][:version].nil? or @vulnerable_version_array[0][:version].empty?
|
36
|
+
return true if @vulnerable_version_array[0][:version].include? dep[:version]
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
data/lib/dawn/knowledge_base.rb
CHANGED
@@ -122,6 +122,39 @@ module Dawn
|
|
122
122
|
|
123
123
|
def find(name)
|
124
124
|
debug_me "I'm asked to find #{name}"
|
125
|
+
debug_me "Please implement find command"
|
126
|
+
end
|
127
|
+
|
128
|
+
# Find all security issues affecting the gem passed as argument.
|
129
|
+
# The gem parameter can contains also the version number, separated by a
|
130
|
+
# ':'
|
131
|
+
#
|
132
|
+
# == Parameters:
|
133
|
+
# string::
|
134
|
+
# A string containing the gem name, and eventually the version, to search
|
135
|
+
# for vulnerabilities.
|
136
|
+
# e.g.
|
137
|
+
# $ dawn kb list sinatra => returns all bulletins affecting sinatra gem
|
138
|
+
# $ dawn kb list sinatra 2.0.0 => return all bulletins affecting
|
139
|
+
# sinatra gem version 2.0.0
|
140
|
+
#
|
141
|
+
# == Returns:
|
142
|
+
# An array with all the vulnerabilities affecting the gem (or the
|
143
|
+
# particular gem version if provided).
|
144
|
+
def find_issues_by_gem(string = "")
|
145
|
+
issues = []
|
146
|
+
@security_checks.each do |check|
|
147
|
+
if check.kind == Dawn::KnowledgeBase::DEPENDENCY_CHECK or check.kind == Dawn::KnowledgeBase::UNSAFE_DEPENDENCY_CHECK
|
148
|
+
debug_me "applying check #{check.name}"
|
149
|
+
name = string.split(':')[0]
|
150
|
+
version = string.split(':')[1]
|
151
|
+
check.please_ignore_dep_version = true if version.nil?
|
152
|
+
check.dependencies = [{:name=>name, :version=>version}]
|
153
|
+
issues << check if check.vuln?
|
154
|
+
end
|
155
|
+
end
|
156
|
+
debug_me "#{issues}"
|
157
|
+
return issues
|
125
158
|
end
|
126
159
|
|
127
160
|
def unpack
|
@@ -187,6 +220,10 @@ module Dawn
|
|
187
220
|
good =0
|
188
221
|
invalid =0
|
189
222
|
|
223
|
+
unless @security_checks.nil?
|
224
|
+
debug_me("KB was previously loaded")
|
225
|
+
return @security_checks
|
226
|
+
end
|
190
227
|
@security_checks = []
|
191
228
|
# $path = File.join(Dir.pwd, "db")
|
192
229
|
|
data/lib/dawn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dawnscanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Perego
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cvss
|
@@ -220,13 +220,12 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
-
description:
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
suggestion.
|
223
|
+
description: dawn is a security source code scanner for ruby powered code. It is especially
|
224
|
+
designed for web applications, but it works also with general purpose ruby scripts.
|
225
|
+
Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra;
|
226
|
+
it provides more than 680 security checks with their own mitigation suggestion.
|
228
227
|
email:
|
229
|
-
- paolo@
|
228
|
+
- paolo@armoredcode.com
|
230
229
|
executables:
|
231
230
|
- dawn
|
232
231
|
extensions: []
|
@@ -273,9 +272,11 @@ files:
|
|
273
272
|
- checksum/dawnscanner-1.6.6.gem.sha1
|
274
273
|
- checksum/dawnscanner-1.6.7.gem.sha1
|
275
274
|
- checksum/dawnscanner-1.6.8.gem.sha1
|
275
|
+
- checksum/dawnscanner-2.0.0.gem.sha1
|
276
276
|
- checksum/dawnscanner-2.0.0.rc1.gem.sha1
|
277
277
|
- checksum/dawnscanner-2.0.0.rc2.gem.sha1
|
278
278
|
- checksum/dawnscanner-2.0.0.rc3.gem.sha1
|
279
|
+
- checksum/dawnscanner-2.0.0.rc5.gem.sha1
|
279
280
|
- code_of_conduct.md
|
280
281
|
- dawnscanner.gemspec
|
281
282
|
- doc/change.sh
|
@@ -341,7 +342,7 @@ files:
|
|
341
342
|
- support/bootstrap.js
|
342
343
|
- support/bootstrap.min.css
|
343
344
|
- support/codesake.css
|
344
|
-
homepage: https://dawnscanner
|
345
|
+
homepage: https://github.com/thesp0nge/dawnscanner
|
345
346
|
licenses:
|
346
347
|
- MIT
|
347
348
|
metadata: {}
|
@@ -353,19 +354,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
353
354
|
requirements:
|
354
355
|
- - ">="
|
355
356
|
- !ruby/object:Gem::Version
|
356
|
-
version:
|
357
|
+
version: 3.0.0
|
357
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
358
359
|
requirements:
|
359
|
-
- - "
|
360
|
+
- - ">="
|
360
361
|
- !ruby/object:Gem::Version
|
361
|
-
version:
|
362
|
+
version: '0'
|
362
363
|
requirements: []
|
363
364
|
rubygems_version: 3.3.26
|
364
365
|
signing_key:
|
365
366
|
specification_version: 4
|
366
|
-
summary:
|
367
|
-
|
368
|
-
secure.
|
367
|
+
summary: dawn is a security source code scanner for ruby powered code. It is crafted
|
368
|
+
with love to make your sinatra, padrino and ruby on rails web applications secure.
|
369
369
|
test_files:
|
370
370
|
- features/dawn_complains_about_an_incorrect_command_line.feature.disabled
|
371
371
|
- features/dawn_scan_a_secure_sinatra_app.feature.disabled
|