dawnscanner 1.2.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +4 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +19 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Changelog.md +412 -0
- data/Gemfile +4 -0
- data/KnowledgeBase.md +213 -0
- data/LICENSE.txt +22 -0
- data/README.md +354 -0
- data/Rakefile +250 -0
- data/Roadmap.md +59 -0
- data/bin/dawn +210 -0
- data/certs/paolo_at_codesake_dot_com.pem +21 -0
- data/checksum/.placeholder +0 -0
- data/checksum/codesake-dawn-1.1.0.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.1.0.rc1.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.1.1.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.1.2.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.1.3.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.2.0.gem.sha512 +1 -0
- data/checksum/codesake-dawn-1.2.99.gem.sha512 +1 -0
- data/dawnscanner.gemspec +43 -0
- data/doc/codesake-dawn.yaml.sample +26 -0
- data/doc/dawn_1_0_announcement.md +139 -0
- data/doc/dawn_1_1_announcement.md +67 -0
- data/doc/dawn_1_2_announcement.md +69 -0
- data/features/dawn_complains_about_an_incorrect_command_line.feature.disabled +21 -0
- data/features/dawn_scan_a_secure_sinatra_app.feature.disabled +31 -0
- data/features/dawn_scan_a_vulnerable_sinatra_app.feature.disabled +36 -0
- data/features/step_definition/dawn_steps.rb +19 -0
- data/features/support/env.rb +1 -0
- data/lib/codesake-dawn.rb +12 -0
- data/lib/codesake/dawn/core.rb +175 -0
- data/lib/codesake/dawn/engine.rb +380 -0
- data/lib/codesake/dawn/gemfile_lock.rb +12 -0
- data/lib/codesake/dawn/kb/basic_check.rb +228 -0
- data/lib/codesake/dawn/kb/combo_check.rb +64 -0
- data/lib/codesake/dawn/kb/cve_2004_0755.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2004_0983.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2005_1992.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2005_2337.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2006_1931.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2006_2582.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2006_3694.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2006_4112.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2006_5467.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2006_6303.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2006_6852.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2006_6979.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2007_0469.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2007_5162.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2007_5379.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2007_5380.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2007_5770.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2007_6077.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2007_6612.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2008_1145.rb +40 -0
- data/lib/codesake/dawn/kb/cve_2008_1891.rb +40 -0
- data/lib/codesake/dawn/kb/cve_2008_2376.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2008_2662.rb +35 -0
- data/lib/codesake/dawn/kb/cve_2008_2663.rb +34 -0
- data/lib/codesake/dawn/kb/cve_2008_2664.rb +35 -0
- data/lib/codesake/dawn/kb/cve_2008_2725.rb +33 -0
- data/lib/codesake/dawn/kb/cve_2008_3655.rb +39 -0
- data/lib/codesake/dawn/kb/cve_2008_3657.rb +39 -0
- data/lib/codesake/dawn/kb/cve_2008_3790.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2008_3905.rb +38 -0
- data/lib/codesake/dawn/kb/cve_2008_4094.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2008_4310.rb +103 -0
- data/lib/codesake/dawn/kb/cve_2008_5189.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2008_7248.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2009_4078.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2009_4124.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2009_4214.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2010_1330.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2010_2489.rb +62 -0
- data/lib/codesake/dawn/kb/cve_2010_3933.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2011_0188.rb +69 -0
- data/lib/codesake/dawn/kb/cve_2011_0446.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_0447.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_0739.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_0995.rb +63 -0
- data/lib/codesake/dawn/kb/cve_2011_1004.rb +36 -0
- data/lib/codesake/dawn/kb/cve_2011_1005.rb +33 -0
- data/lib/codesake/dawn/kb/cve_2011_2197.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2011_2686.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2011_2705.rb +34 -0
- data/lib/codesake/dawn/kb/cve_2011_2929.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2011_2930.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_2931.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2011_2932.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2011_3009.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_3186.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2011_3187.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2011_4319.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2011_4815.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2011_5036.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_1098.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2012_1099.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_1241.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_2139.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_2140.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_2660.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_2661.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_2671.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_2694.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2012_2695.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_3424.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2012_3463.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_3464.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_3465.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_4464.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_4466.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_4481.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2012_4522.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_5370.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_5371.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_5380.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_6109.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2012_6134.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2012_6496.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2012_6497.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_0155.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_0156.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0162.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_0175.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0183.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0184.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0233.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_0256.rb +61 -0
- data/lib/codesake/dawn/kb/cve_2013_0262.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_0263.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_0269.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0276.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_0277.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_0284.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0285.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_0333.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_1607.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_1655.rb +67 -0
- data/lib/codesake/dawn/kb/cve_2013_1656.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_1756.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_1800.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_1801.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1802.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1812.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1821.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_1854.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_1855.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_1856.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_1857.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1875.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1898.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1911.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_1933.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1947.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_1948.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_2065.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_2090.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_2105.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_2119.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_2512.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_2513.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_2516.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_2615.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_2616.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_2617.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_3221.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_4164.rb +32 -0
- data/lib/codesake/dawn/kb/cve_2013_4203.rb +27 -0
- data/lib/codesake/dawn/kb/cve_2013_4389.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_4413.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_4457.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_4478.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_4479.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_4489.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_4491.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_4492.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_4562.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_4593.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2013_5647.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_5671.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2013_6414.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_6415.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_6416.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_6417.rb +31 -0
- data/lib/codesake/dawn/kb/cve_2013_6421.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_6459.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2013_6460.rb +55 -0
- data/lib/codesake/dawn/kb/cve_2013_6461.rb +59 -0
- data/lib/codesake/dawn/kb/cve_2013_7086.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2014_0036.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2014_0080.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2014_0081.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2014_0082.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2014_0130.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2014_1233.rb +29 -0
- data/lib/codesake/dawn/kb/cve_2014_1234.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2014_2322.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2014_2525.rb +61 -0
- data/lib/codesake/dawn/kb/cve_2014_2538.rb +28 -0
- data/lib/codesake/dawn/kb/cve_2014_3482.rb +30 -0
- data/lib/codesake/dawn/kb/cve_2014_3483.rb +29 -0
- data/lib/codesake/dawn/kb/dependency_check.rb +86 -0
- data/lib/codesake/dawn/kb/deprecation_check.rb +40 -0
- data/lib/codesake/dawn/kb/not_revised_code.rb +24 -0
- data/lib/codesake/dawn/kb/operating_system_check.rb +98 -0
- data/lib/codesake/dawn/kb/osvdb_105971.rb +31 -0
- data/lib/codesake/dawn/kb/osvdb_108530.rb +29 -0
- data/lib/codesake/dawn/kb/osvdb_108563.rb +30 -0
- data/lib/codesake/dawn/kb/osvdb_108569.rb +30 -0
- data/lib/codesake/dawn/kb/osvdb_108570.rb +29 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet.rb +41 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/check_for_backup_files.rb +22 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb +59 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/command_injection.rb +30 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/csrf.rb +31 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/mass_assignment_in_model.rb +35 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb +38 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/sensitive_files.rb +31 -0
- data/lib/codesake/dawn/kb/owasp_ror_cheatsheet/session_stored_in_database.rb +33 -0
- data/lib/codesake/dawn/kb/pattern_match_check.rb +129 -0
- data/lib/codesake/dawn/kb/ruby_version_check.rb +91 -0
- data/lib/codesake/dawn/kb/simpleform_xss_20131129.rb +30 -0
- data/lib/codesake/dawn/kb/version_check.rb +418 -0
- data/lib/codesake/dawn/knowledge_base.rb +513 -0
- data/lib/codesake/dawn/padrino.rb +82 -0
- data/lib/codesake/dawn/rails.rb +17 -0
- data/lib/codesake/dawn/railtie.rb +9 -0
- data/lib/codesake/dawn/reporter.rb +280 -0
- data/lib/codesake/dawn/sinatra.rb +129 -0
- data/lib/codesake/dawn/tasks.rb +27 -0
- data/lib/codesake/dawn/utils.rb +21 -0
- data/lib/codesake/dawn/version.rb +28 -0
- data/lib/tasks/codesake-dawn_tasks.rake +1 -0
- data/spec/lib/dawn/codesake_core_spec.rb +9 -0
- data/spec/lib/dawn/codesake_knowledgebase_spec.rb +940 -0
- data/spec/lib/dawn/codesake_padrino_engine_disabled.rb +45 -0
- data/spec/lib/dawn/codesake_rails_engine_disabled.rb +12 -0
- data/spec/lib/dawn/codesake_sinatra_engine_disabled.rb +128 -0
- data/spec/lib/kb/codesake_cve_2013_0175_spec.rb +35 -0
- data/spec/lib/kb/codesake_cve_2013_4457_spec.rb +41 -0
- data/spec/lib/kb/codesake_dependency_version_check_spec.rb +76 -0
- data/spec/lib/kb/codesake_deprecation_check_spec.rb +56 -0
- data/spec/lib/kb/codesake_ruby_version_check_spec.rb +40 -0
- data/spec/lib/kb/codesake_version_check_spec.rb +165 -0
- data/spec/lib/kb/cve_2011_2705_spec.rb +35 -0
- data/spec/lib/kb/cve_2011_2930_spec.rb +31 -0
- data/spec/lib/kb/cve_2011_3009_spec.rb +25 -0
- data/spec/lib/kb/cve_2011_3187_spec.rb +24 -0
- data/spec/lib/kb/cve_2011_4319_spec.rb +44 -0
- data/spec/lib/kb/cve_2011_5036_spec.rb +95 -0
- data/spec/lib/kb/cve_2012_1098_spec.rb +36 -0
- data/spec/lib/kb/cve_2012_2139_spec.rb +20 -0
- data/spec/lib/kb/cve_2012_2671_spec.rb +23 -0
- data/spec/lib/kb/cve_2012_6109_spec.rb +112 -0
- data/spec/lib/kb/cve_2013_0162_spec.rb +23 -0
- data/spec/lib/kb/cve_2013_0183_spec.rb +54 -0
- data/spec/lib/kb/cve_2013_0184_spec.rb +115 -0
- data/spec/lib/kb/cve_2013_0256_spec.rb +34 -0
- data/spec/lib/kb/cve_2013_0262_spec.rb +44 -0
- data/spec/lib/kb/cve_2013_0263_spec.rb +11 -0
- data/spec/lib/kb/cve_2013_1607_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_1655_spec.rb +31 -0
- data/spec/lib/kb/cve_2013_1756_spec.rb +23 -0
- data/spec/lib/kb/cve_2013_2090_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_2105_spec.rb +11 -0
- data/spec/lib/kb/cve_2013_2119_spec.rb +27 -0
- data/spec/lib/kb/cve_2013_2512_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_2513_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_2516_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_4203_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_4413_spec.rb +16 -0
- data/spec/lib/kb/cve_2013_4489_spec.rb +63 -0
- data/spec/lib/kb/cve_2013_4593_spec.rb +16 -0
- data/spec/lib/kb/cve_2013_5647_spec.rb +19 -0
- data/spec/lib/kb/cve_2013_5671_spec.rb +27 -0
- data/spec/lib/kb/cve_2013_6416_spec.rb +31 -0
- data/spec/lib/kb/cve_2013_6459_spec.rb +15 -0
- data/spec/lib/kb/cve_2013_7086_spec.rb +22 -0
- data/spec/lib/kb/cve_2014_0036_spec.rb +15 -0
- data/spec/lib/kb/cve_2014_0080_spec.rb +28 -0
- data/spec/lib/kb/cve_2014_0081_spec.rb +68 -0
- data/spec/lib/kb/cve_2014_0082_spec.rb +52 -0
- data/spec/lib/kb/cve_2014_0130_spec.rb +19 -0
- data/spec/lib/kb/cve_2014_1233_spec.rb +15 -0
- data/spec/lib/kb/cve_2014_1234_spec.rb +16 -0
- data/spec/lib/kb/cve_2014_2322_spec.rb +15 -0
- data/spec/lib/kb/cve_2014_2538_spec.rb +15 -0
- data/spec/lib/kb/cve_2014_3482_spec.rb +15 -0
- data/spec/lib/kb/cve_2014_3483_spec.rb +23 -0
- data/spec/lib/kb/osvdb_105971_spec.rb +15 -0
- data/spec/lib/kb/osvdb_108530_spec.rb +22 -0
- data/spec/lib/kb/osvdb_108563_spec.rb +18 -0
- data/spec/lib/kb/osvdb_108569_spec.rb +17 -0
- data/spec/lib/kb/osvdb_108570_spec.rb +17 -0
- data/spec/lib/kb/owasp_ror_cheatsheet_disabled.rb +56 -0
- data/spec/spec_helper.rb +11 -0
- data/support/bootstrap.js +2027 -0
- data/support/bootstrap.min.css +9 -0
- data/support/codesake.css +63 -0
- metadata +659 -0
- metadata.gz.sig +0 -0
data/Rakefile
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
# require "highline/import"
|
4
|
+
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
require "codesake/dawn/utils"
|
10
|
+
require "codesake/dawn/knowledge_base"
|
11
|
+
|
12
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
13
|
+
t.cucumber_opts = "features --format pretty -x"
|
14
|
+
t.fork = false
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new do |t|
|
18
|
+
t.rspec_opts = ["--color"]
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
task :default => [ :spec, :features, :kb ]
|
23
|
+
task :test => :spec
|
24
|
+
task :prepare => [:build, :'checksum:calculate', :'checksum:commit']
|
25
|
+
task :release => [:prepare]
|
26
|
+
|
27
|
+
# namespace :check do
|
28
|
+
# desc "Create a dependency check"
|
29
|
+
# task :dependency, :name do |t, args|
|
30
|
+
# end
|
31
|
+
|
32
|
+
# end
|
33
|
+
desc "Create a new CVE test"
|
34
|
+
task :cve, :name do |t,args|
|
35
|
+
name = args.name
|
36
|
+
SRC_DIR = "./lib/codesake/dawn/kb/"
|
37
|
+
SPEC_DIR = "./spec/lib/kb/"
|
38
|
+
|
39
|
+
raise "### It seems that #{name} is already in Dawn knowledge base" unless Codesake::Dawn::KnowledgeBase.find(nil, name).nil?
|
40
|
+
raise "### Invalid CVE title: #{name}" if name.nil? or name.empty? or /CVE-\d{4}-\d{4}/.match(name).nil?
|
41
|
+
raise "### No target directory: #{SRC_DIR}" unless Dir.exists?(SRC_DIR)
|
42
|
+
raise "### No rspec directory: #{SPEC_DIR}" unless Dir.exists?(SPEC_DIR)
|
43
|
+
|
44
|
+
puts "Adding #{name} to knowledge base..."
|
45
|
+
|
46
|
+
rb_filename = SRC_DIR+name.downcase.gsub("-", "_")+".rb"
|
47
|
+
spec_filename = SPEC_DIR+name.downcase.gsub("-", "_")+"_spec.rb"
|
48
|
+
class_name = name.gsub("-", "_")
|
49
|
+
|
50
|
+
open(rb_filename, "w") do |file|
|
51
|
+
file.puts "module Codesake"
|
52
|
+
file.puts "\tmodule Dawn"
|
53
|
+
file.puts "\t\tmodule Kb"
|
54
|
+
file.puts "\t\t\t# Automatically created with rake on #{Time.now.strftime('%Y-%m-%d')}"
|
55
|
+
file.puts "\t\t\tclass #{class_name}"
|
56
|
+
file.puts "\t\t\t\t# Include the testing skeleton for this CVE"
|
57
|
+
file.puts "\t\t\t\t# include PatternMatchCheck"
|
58
|
+
file.puts "\t\t\t\t# include DependencyCheck"
|
59
|
+
file.puts "\t\t\t\t# include RubyVersionCheck"
|
60
|
+
file.puts ""
|
61
|
+
file.puts "\t\t\t\tdef initialize"
|
62
|
+
file.puts "\t\t\t\tend"
|
63
|
+
file.puts "\t\t\tend"
|
64
|
+
file.puts "\t\tend"
|
65
|
+
file.puts "\tend"
|
66
|
+
file.puts "end"
|
67
|
+
end
|
68
|
+
puts "#{rb_filename} created"
|
69
|
+
|
70
|
+
open(spec_filename, "w") do |file|
|
71
|
+
file.puts "require 'spec_helper'"
|
72
|
+
|
73
|
+
file.puts "describe \"The #{name} vulnerability\" do"
|
74
|
+
file.puts "\tbefore(:all) do"
|
75
|
+
file.puts "\t\t@check = Codesake::Dawn::Kb::#{class_name}.new"
|
76
|
+
file.puts "\t\t# @check.debug = true"
|
77
|
+
file.puts "\tend"
|
78
|
+
file.puts "\tit \"is reported when...\""
|
79
|
+
file.puts "end"
|
80
|
+
end
|
81
|
+
puts "#{spec_filename} created"
|
82
|
+
|
83
|
+
puts "*** PLEASE IMPLEMENT TEST FOR #{name} IN spec/lib/dawn/codesake_knowledgebase_spec.rb in order to reflect changes"
|
84
|
+
puts "*** PLEASE ADD THIS CODE IN lib/codesake/dawn/knowledge_base.rb in order to reflect changes"
|
85
|
+
puts "require \"codesake/dawn/kb/#{class_name.downcase}\""
|
86
|
+
puts "it \"must have test for #{name}\" do"
|
87
|
+
puts " sc = kb.find(\"#{name}\")"
|
88
|
+
puts " sc.should_not be_nil"
|
89
|
+
puts " sc.class.should == Codesake::Dawn::Kb::#{class_name}"
|
90
|
+
puts "end"
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
desc "Create a new Generic security check"
|
98
|
+
task :check, :name do |t,args|
|
99
|
+
name = args.name
|
100
|
+
SRC_DIR = "./lib/codesake/dawn/kb/"
|
101
|
+
SPEC_DIR = "./spec/lib/kb/"
|
102
|
+
|
103
|
+
raise "### It seems that #{name} is already in Dawn knowledge base" unless Codesake::Dawn::KnowledgeBase.find(nil, name).nil?
|
104
|
+
raise "### No target directory: #{SRC_DIR}" unless Dir.exists?(SRC_DIR)
|
105
|
+
raise "### No rspec directory: #{SPEC_DIR}" unless Dir.exists?(SPEC_DIR)
|
106
|
+
|
107
|
+
puts "Adding #{name} to knowledge base..."
|
108
|
+
|
109
|
+
rb_filename = SRC_DIR+name.downcase.gsub("-", "_")+".rb"
|
110
|
+
spec_filename = SPEC_DIR+name.downcase.gsub("-", "_")+"_spec.rb"
|
111
|
+
class_name = name.gsub("-", "_")
|
112
|
+
|
113
|
+
open(rb_filename, "w") do |file|
|
114
|
+
file.puts "module Codesake"
|
115
|
+
file.puts "\tmodule Dawn"
|
116
|
+
file.puts "\t\tmodule Kb"
|
117
|
+
file.puts "\t\t\t# Automatically created with rake on #{Time.now.strftime('%Y-%m-%d')}"
|
118
|
+
file.puts "\t\t\tclass #{class_name}"
|
119
|
+
file.puts "\t\t\t\t# Include the testing skeleton for this Security Check"
|
120
|
+
file.puts "\t\t\t\t# include PatternMatchCheck"
|
121
|
+
file.puts "\t\t\t\t# include DependencyCheck"
|
122
|
+
file.puts "\t\t\t\t# include RubyVersionCheck"
|
123
|
+
file.puts ""
|
124
|
+
file.puts "\t\t\t\tdef initialize"
|
125
|
+
file.puts "\t\t\t\tend"
|
126
|
+
file.puts "\t\t\tend"
|
127
|
+
file.puts "\t\tend"
|
128
|
+
file.puts "\tend"
|
129
|
+
file.puts "end"
|
130
|
+
end
|
131
|
+
puts "#{rb_filename} created"
|
132
|
+
|
133
|
+
open(spec_filename, "w") do |file|
|
134
|
+
file.puts "require 'spec_helper'"
|
135
|
+
|
136
|
+
file.puts "describe \"The #{name} vulnerability\" do"
|
137
|
+
file.puts "\tbefore(:all) do"
|
138
|
+
file.puts "\t\t@check = Codesake::Dawn::Kb::#{class_name}.new"
|
139
|
+
file.puts "\t\t# @check.debug = true"
|
140
|
+
file.puts "\tend"
|
141
|
+
file.puts "\tit \"is reported when...\""
|
142
|
+
file.puts "end"
|
143
|
+
end
|
144
|
+
puts "#{spec_filename} created"
|
145
|
+
|
146
|
+
|
147
|
+
puts "*** PLEASE IMPLEMENT TEST FOR #{name} IN spec/lib/dawn/codesake_knowledgebase_spec.rb in order to reflect changes"
|
148
|
+
puts "*** PLEASE ADD THIS CODE IN lib/codesake/dawn/knowledge_base.rb in order to reflect changes"
|
149
|
+
puts "require \"codesake/dawn/kb/#{class_name.downcase}\""
|
150
|
+
puts "it \"must have test for #{name}\" do"
|
151
|
+
puts " sc = kb.find(\"#{name}\")"
|
152
|
+
puts " sc.should_not be_nil"
|
153
|
+
puts " sc.class.should == Codesake::Dawn::Kb::#{class_name}"
|
154
|
+
puts "end"
|
155
|
+
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
namespace :kb do
|
160
|
+
desc 'Check information lint'
|
161
|
+
task :lint do
|
162
|
+
Codesake::Dawn::KnowledgeBase.new.all.each do |check|
|
163
|
+
l = check.lint
|
164
|
+
puts "check #{check.name} has this attribute(s) with a nil value: #{l.to_s}" unless l.size == 0
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
desc 'Creates a KnowledgeBase.md file'
|
169
|
+
task :create do
|
170
|
+
checks = Codesake::Dawn::KnowledgeBase.new.all
|
171
|
+
open("KnowledgeBase.md", "w") do |file|
|
172
|
+
file.puts "# Codesake::Dawn Knowledge base"
|
173
|
+
file.puts "\nThe knowledge base library for Codesake::Dawn version #{Codesake::Dawn::VERSION} contains #{checks.count} security checks."
|
174
|
+
file.puts "---"
|
175
|
+
checks.each do |c|
|
176
|
+
file.puts "* [#{c.name}](#{c.cve_link}): #{c.message}" if c.name.start_with?('CVE')
|
177
|
+
file.puts "* [#{c.name}](#{c.osvdb_link}): #{c.message}" if c.name.start_with?('OSVDB')
|
178
|
+
file.puts "* #{c.name}: #{c.message}" unless c.name.start_with?('CVE')
|
179
|
+
end
|
180
|
+
|
181
|
+
file.puts "\n\n_Last updated: #{Time.now.strftime("%a %d %b %T %Z %Y")}_"
|
182
|
+
end
|
183
|
+
puts "KnowledgeBase.md file successfully generated"
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
require 'digest/sha2'
|
189
|
+
namespace :checksum do
|
190
|
+
|
191
|
+
desc 'Calculate gem checksum'
|
192
|
+
task :calculate do
|
193
|
+
system 'mkdir -p checksum > /dev/null'
|
194
|
+
built_gem_path = "pkg/codesake-dawn-#{Codesake::Dawn::VERSION}.gem"
|
195
|
+
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
|
196
|
+
checksum_path = "checksum/codesake-dawn-#{Codesake::Dawn::VERSION}.gem.sha512"
|
197
|
+
File.open(checksum_path, 'w' ) {|f| f.write(checksum) }
|
198
|
+
|
199
|
+
puts "#{checksum_path}: #{checksum}"
|
200
|
+
end
|
201
|
+
|
202
|
+
desc 'Add and commit latest checksum'
|
203
|
+
task :commit do
|
204
|
+
checksum_path = "checksum/codesake-dawn-#{Codesake::Dawn::VERSION}.gem.sha512"
|
205
|
+
system "git add #{checksum_path}"
|
206
|
+
system "git commit -v #{checksum_path} -m \"Adding #{Codesake::Dawn::VERSION} checksum to repo\""
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
###############################################################################
|
211
|
+
# ruby-advisory-rb integration
|
212
|
+
###############################################################################
|
213
|
+
|
214
|
+
namespace :rubysec do
|
215
|
+
desc 'Find new CVE bulletins to add to Codesake::Dawn'
|
216
|
+
task :find do
|
217
|
+
git_url = 'git@github.com:rubysec/ruby-advisory-db.git'
|
218
|
+
target_dir = './tmp/'
|
219
|
+
system "mkdir -p #{target_dir}"
|
220
|
+
system "rm -rf #{target_dir}ruby-advisory-db"
|
221
|
+
system "git clone #{git_url} #{target_dir}ruby-advisory-db"
|
222
|
+
list = []
|
223
|
+
Dir.glob("#{target_dir}ruby-advisory-db/gems/*/*.yml") do |path|
|
224
|
+
advisory = YAML.load_file(path)
|
225
|
+
if advisory['cve']
|
226
|
+
cve = "CVE-"+advisory['cve']
|
227
|
+
# Exclusion
|
228
|
+
# CVE-2007-6183 is a vulnerability in gnome2 ruby binding. Not a gem, I don't care
|
229
|
+
# CVE-2013-1878 is a duplicate of CVE-2013-2617 that is in knowledge base
|
230
|
+
# CVE-2013-1876 is a duplicate of CVE-2013-2615 that is in knowledge base
|
231
|
+
exclusion = ["CVE-2007-6183", "CVE-2013-1876", "CVE-2013-1878"]
|
232
|
+
if exclusion.include?(cve)
|
233
|
+
puts "#{cve} is in the exclusion list"
|
234
|
+
else
|
235
|
+
found = Codesake::Dawn::KnowledgeBase.find(nil, cve)
|
236
|
+
puts "#{cve} NOT in dawn v#{Codesake::Dawn::VERSION} knowledge base" unless found
|
237
|
+
list << cve unless found
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
unless list.empty?
|
242
|
+
File.open("missing_rubyadvisory_cvs_#{Time.now.strftime("%Y%m%d")}.txt", "w") do |f|
|
243
|
+
f.puts "Missing CVE bulletins - v#{Codesake::Dawn::VERSION} - #{Time.now.strftime("%d %B %Y")}"
|
244
|
+
f.puts list
|
245
|
+
end
|
246
|
+
end
|
247
|
+
system "rm -rf #{target_dir}ruby-advisory-db"
|
248
|
+
|
249
|
+
end
|
250
|
+
end
|
data/Roadmap.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Codesake Dawn - roadmap
|
2
|
+
|
3
|
+
Codesake::Dawn is a static analysis security scanner for ruby written web applications.
|
4
|
+
It supports [Sinatra](http://www.sinatrarb.com),
|
5
|
+
[Padrino](http://www.padrinorb.com) and [Ruby on Rails](http://rubyonrails.org)
|
6
|
+
frameworks.
|
7
|
+
|
8
|
+
This is an ongoing roadmap for the Codesake::Dawn source code review tool.
|
9
|
+
|
10
|
+
_latest update: Mon Mar 31 13:01:21 CEST 2014_
|
11
|
+
|
12
|
+
## Version 1.2.0
|
13
|
+
|
14
|
+
* create a task to check for new CVE in NVD website
|
15
|
+
* SQLite3 integration for saving data. Each project will have its own SQLite
|
16
|
+
database containing reviews, findings and all. A table with Codesake::Dawn version it
|
17
|
+
created the database will be inserted as well
|
18
|
+
* add a language check. It will handle a ruby script as input and a
|
19
|
+
ruby\_parser line as unsafe pattern. It will compile the ruby and look for
|
20
|
+
the unsafe pattern
|
21
|
+
* Add preliminary Cross Site Scripting detection for Ruby on Rails.
|
22
|
+
* Issue #7: Improving HTML output and let the user the capability to provide a
|
23
|
+
basic layout to customize report
|
24
|
+
* Add a ruby deprecation check, accordingly to
|
25
|
+
https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
|
26
|
+
|
27
|
+
## Version 1.3.0
|
28
|
+
|
29
|
+
* Add support for ERB for in detect\_views
|
30
|
+
* Add preliminary javascript support
|
31
|
+
* adding test for CVE-2011-4969 XSS in jquery < 1.6.2
|
32
|
+
* add support for pure Rack applications
|
33
|
+
* Cross Site Scripting detection: it must be done for all MVC frameworks
|
34
|
+
(including Rack) and it must cover either reflected than stored attack
|
35
|
+
patterns
|
36
|
+
* Add a --github option to Codesake::Dawn to clone a remote repository, perform
|
37
|
+
a bundle install and do a code review.
|
38
|
+
* Add support for github hooks
|
39
|
+
* Add premilinary SQL injection detection for Ruby on Rails
|
40
|
+
|
41
|
+
## Version 1.5.0
|
42
|
+
|
43
|
+
* Add insecure direct object reference detection for all MVC frameworks (including Rack)
|
44
|
+
* SQL Injection detection: it must be done for all MVC frameworks (including Rack)
|
45
|
+
* Add automatic mitigation patch generation
|
46
|
+
* Add support for Javascript
|
47
|
+
|
48
|
+
# Spinoff projects
|
49
|
+
|
50
|
+
Codesake::Dawn is a security scanner for ruby code. Modern web applications
|
51
|
+
however are wrote in a plenty of great technologies deserving a good tool for
|
52
|
+
security scan.
|
53
|
+
|
54
|
+
Node.js and Go are very promising programming languages and a tool similiar to
|
55
|
+
Codesake::Dawn can be wrote also to support them:
|
56
|
+
|
57
|
+
Initially they were in the Codesake::Dawn roadmap for a 2.0.0 version. However
|
58
|
+
we decide to drop this in the name of being focused on ruby programming
|
59
|
+
language.
|
data/bin/dawn
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'getoptlong'
|
4
|
+
require 'json'
|
5
|
+
require 'terminal-table'
|
6
|
+
|
7
|
+
require 'justify'
|
8
|
+
|
9
|
+
require 'codesake-commons'
|
10
|
+
require 'codesake-dawn'
|
11
|
+
|
12
|
+
APPNAME = File.basename($0)
|
13
|
+
LIST_KNOWN_FRAMEWORK = %w(rails sinatra padrino)
|
14
|
+
VALID_OUTPUT_FORMAT = %w(console json csv html)
|
15
|
+
|
16
|
+
$logger = Codesake::Commons::Logging.instance
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
# report formatting options
|
19
|
+
[ '--ascii-tabular-report', '-a', GetoptLong::NO_ARGUMENT],
|
20
|
+
[ '--json', '-j', GetoptLong::NO_ARGUMENT],
|
21
|
+
[ '--html', '-H', GetoptLong::NO_ARGUMENT],
|
22
|
+
|
23
|
+
# MVC forcing
|
24
|
+
[ '--rails', '-r', GetoptLong::NO_ARGUMENT],
|
25
|
+
[ '--sinatra', '-s', GetoptLong::NO_ARGUMENT],
|
26
|
+
[ '--padrino', '-p', GetoptLong::NO_ARGUMENT],
|
27
|
+
|
28
|
+
[ '--gem-lock', '-G', GetoptLong::REQUIRED_ARGUMENT],
|
29
|
+
[ '--count-only', '-C', GetoptLong::NO_ARGUMENT],
|
30
|
+
[ '--exit-on-warn', '-z', GetoptLong::NO_ARGUMENT],
|
31
|
+
|
32
|
+
# Disable checks by family type
|
33
|
+
[ '--disable-cve-bulletins', GetoptLong::NO_ARGUMENT],
|
34
|
+
[ '--disable-code-quality', GetoptLong::NO_ARGUMENT],
|
35
|
+
[ '--disable-code-style', GetoptLong::NO_ARGUMENT],
|
36
|
+
[ '--disable-owasp-ror-cheatsheet', GetoptLong::NO_ARGUMENT],
|
37
|
+
[ '--disable-owasp-top-10', GetoptLong::NO_ARGUMENT],
|
38
|
+
|
39
|
+
# Search knowledge base
|
40
|
+
[ '--search-knowledge-base', '-S', GetoptLong::REQUIRED_ARGUMENT],
|
41
|
+
# List stuff
|
42
|
+
[ '--list-knowledge-base', GetoptLong::NO_ARGUMENT],
|
43
|
+
[ '--list-known-framework', GetoptLong::NO_ARGUMENT],
|
44
|
+
[ '--list-known-families', GetoptLong::NO_ARGUMENT],
|
45
|
+
# please save output to file
|
46
|
+
[ '--file', '-F', GetoptLong::REQUIRED_ARGUMENT],
|
47
|
+
# specify an alternate config file
|
48
|
+
[ '--config-file', '-c', GetoptLong::REQUIRED_ARGUMENT],
|
49
|
+
|
50
|
+
# service options
|
51
|
+
[ '--verbose', '-V', GetoptLong::NO_ARGUMENT],
|
52
|
+
[ '--debug', '-D', GetoptLong::NO_ARGUMENT],
|
53
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT],
|
54
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT]
|
55
|
+
)
|
56
|
+
opts.quiet=true
|
57
|
+
|
58
|
+
engine = nil
|
59
|
+
|
60
|
+
|
61
|
+
options = Codesake::Dawn::Core.read_conf(Codesake::Dawn::Core.find_conf(true))
|
62
|
+
check = ""
|
63
|
+
guess = {:name=>"", :version=>"", :connected_gems=>[]}
|
64
|
+
|
65
|
+
begin
|
66
|
+
opts.each do |opt, val|
|
67
|
+
case opt
|
68
|
+
when '--version'
|
69
|
+
puts "#{Codesake::Dawn::VERSION} [#{Codesake::Dawn::CODENAME}]"
|
70
|
+
Kernel.exit(0)
|
71
|
+
when '--config-file'
|
72
|
+
options = Codesake::Dawn::Core.read_conf(val)
|
73
|
+
when '--disable-cve-bulletins'
|
74
|
+
options[:enabled_checks].delete(:cve_bulletin)
|
75
|
+
when '--disable-code-quality'
|
76
|
+
options[:enabled_checks].delete(:code_quality)
|
77
|
+
when '--disable-code-style'
|
78
|
+
options[:enabled_checks].delete(:code_style)
|
79
|
+
when '--disable-owasp-ror-cheatsheet'
|
80
|
+
options[:enabled_checks].delete(:owasp_ror_cheatsheet)
|
81
|
+
when '--disable-owasp-top-10'
|
82
|
+
options[:enabled_checks].delete(:owasp_top_10_1)
|
83
|
+
options[:enabled_checks].delete(:owasp_top_10_2)
|
84
|
+
options[:enabled_checks].delete(:owasp_top_10_3)
|
85
|
+
options[:enabled_checks].delete(:owasp_top_10_4)
|
86
|
+
options[:enabled_checks].delete(:owasp_top_10_5)
|
87
|
+
options[:enabled_checks].delete(:owasp_top_10_6)
|
88
|
+
options[:enabled_checks].delete(:owasp_top_10_7)
|
89
|
+
options[:enabled_checks].delete(:owasp_top_10_8)
|
90
|
+
options[:enabled_checks].delete(:owasp_top_10_9)
|
91
|
+
options[:enabled_checks].delete(:owasp_top_10_10)
|
92
|
+
when '--list-known-families'
|
93
|
+
printf "Codesake::Dawn supports following check families:\n\n"
|
94
|
+
puts Codesake::Dawn::Kb::BasicCheck.families
|
95
|
+
Kernel.exit(0)
|
96
|
+
when '--json'
|
97
|
+
options[:output] = "json"
|
98
|
+
when '--ascii-tabular-report'
|
99
|
+
options[:output] = "tabular"
|
100
|
+
when '--html'
|
101
|
+
options[:output] = "html"
|
102
|
+
when '--rails'
|
103
|
+
options[:mvc]=:rails
|
104
|
+
when '--sinatra'
|
105
|
+
options[:mvc]=:sinatra
|
106
|
+
when '--padrino'
|
107
|
+
options[:mvc]=:padrino
|
108
|
+
when '--file'
|
109
|
+
options[:filename] = val
|
110
|
+
when '--gem-lock'
|
111
|
+
options[:gemfile_scan] = true
|
112
|
+
unless val.empty?
|
113
|
+
options[:gemfile_name] = val
|
114
|
+
guess = Codesake::Dawn::Core.guess_mvc(val)
|
115
|
+
end
|
116
|
+
when '--verbose'
|
117
|
+
options[:verbose]=true
|
118
|
+
when '--count-only'
|
119
|
+
options[:output] = "count"
|
120
|
+
when '--debug'
|
121
|
+
options[:debug] = true
|
122
|
+
when '--exit-on-warn'
|
123
|
+
options[:exit_on_warn] = true
|
124
|
+
|
125
|
+
when '--search-knowledge-base'
|
126
|
+
found = Codesake::Dawn::KnowledgeBase.find(nil, val)
|
127
|
+
puts "#{val} found in knowledgebase." if found
|
128
|
+
puts "#{val} not found in knowledgebase" if ! found
|
129
|
+
Kernel.exit(0)
|
130
|
+
|
131
|
+
when '--list-knowledge-base'
|
132
|
+
puts Codesake::Dawn::Core.dump_knowledge_base(options[:verbose])
|
133
|
+
Kernel.exit(0)
|
134
|
+
when '--list-known-framework'
|
135
|
+
puts "Ruby MVC framework supported by #{APPNAME}:"
|
136
|
+
LIST_KNOWN_FRAMEWORK.each do |mvc|
|
137
|
+
puts "* #{mvc}"
|
138
|
+
end
|
139
|
+
Kernel.exit(0)
|
140
|
+
when '--help'
|
141
|
+
Kernel.exit(Codesake::Dawn::Core.help)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
rescue GetoptLong::InvalidOption => e
|
145
|
+
|
146
|
+
$logger.helo APPNAME, Codesake::Dawn::VERSION
|
147
|
+
$logger.err e.message
|
148
|
+
Kernel.exit(Codesake::Dawn::Core.help)
|
149
|
+
end
|
150
|
+
|
151
|
+
target=ARGV.shift
|
152
|
+
|
153
|
+
$logger.helo APPNAME, Codesake::Dawn::VERSION
|
154
|
+
trap("INT") { $logger.die('[INTERRUPTED]') }
|
155
|
+
$logger.die("missing target") if target.nil? && options[:gemfile_name].empty?
|
156
|
+
$logger.die("invalid directory (#{target})") if options[:gemfile_name].empty? &&! Codesake::Dawn::Core.is_good_target?(target)
|
157
|
+
$logger.die("if scanning Gemfile.lock file you must not force target MVC using one from -r, -s or -p flag") if ! options[:mvc].empty? && options[:gemfile_scan]
|
158
|
+
$logger.log("security check enabled: #{options[:enabled_checks]}") if options[:debug]
|
159
|
+
|
160
|
+
|
161
|
+
## MVC auto detect.
|
162
|
+
# Skipping MVC autodetect if it's already been done by guess_mvc when choosing Gemfile.lock scan
|
163
|
+
|
164
|
+
unless options[:gemfile_scan]
|
165
|
+
begin
|
166
|
+
if options[:mvc].empty?
|
167
|
+
engine = Codesake::Dawn::Core.detect_mvc(target)
|
168
|
+
$logger.log("using #{engine.class.name} engine via autodect") if options[:debug]
|
169
|
+
else
|
170
|
+
engine = Codesake::Dawn::Rails.new(target) if options[:mvc] == :rails
|
171
|
+
engine = Codesake::Dawn::Sinatra.new(target) if options[:mvc] == :sinatra
|
172
|
+
engine = Codesake::Dawn::Padrino.new(target) if options[:mvc] == :padrino
|
173
|
+
end
|
174
|
+
rescue ArgumentError => e
|
175
|
+
$logger.die(e.message)
|
176
|
+
end
|
177
|
+
else
|
178
|
+
engine = Codesake::Dawn::GemfileLock.new(target, options[:gemfile_name], guess) # if options[:gemfile_scan]
|
179
|
+
end
|
180
|
+
|
181
|
+
$logger.die("ruby framework auto detect failed. Please force if rails, sinatra or padrino with -r, -s or -p flags") if engine.nil?
|
182
|
+
|
183
|
+
if options[:exit_on_warn]
|
184
|
+
Kernel.at_exit do
|
185
|
+
if engine.count_vulnerabilities != 0
|
186
|
+
Kernel.exit(engine.count_vulnerabilities)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
if options[:debug]
|
192
|
+
$logger.warn "putting engine in debug mode"
|
193
|
+
engine.debug = true
|
194
|
+
end
|
195
|
+
|
196
|
+
$logger.die "missing target framework option" if engine.nil?
|
197
|
+
$logger.warn "this is a development Codesake::Dawn version" if Codesake::Dawn::RELEASE == "(development)"
|
198
|
+
$logger.die "nothing to do on #{target}" if ! options[:gemfile_scan] && ! engine.can_apply?
|
199
|
+
|
200
|
+
engine.load_knowledge_base(options[:enabled_checks])
|
201
|
+
ret = engine.apply_all
|
202
|
+
|
203
|
+
if options[:output] == "count"
|
204
|
+
puts (ret)? engine.vulnerabilities.count : "-1" unless options[:output] == "json"
|
205
|
+
puts (ret)? {:status=>"OK", :vulnerabilities_count=>engine.count_vulnerabilities}.to_json : {:status=>"KO", :vulnerabilities_count=>-1}.to_json
|
206
|
+
Kernel.exit(0)
|
207
|
+
end
|
208
|
+
|
209
|
+
Codesake::Dawn::Reporter.new({:engine=>engine, :apply_all_code=>ret, :format=>options[:output].to_sym, :filename=>options[:filename]}).report
|
210
|
+
$logger.bye
|