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
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'ruby_parser'
|
2
|
+
module Codesake
|
3
|
+
module Dawn
|
4
|
+
class Padrino
|
5
|
+
include Codesake::Dawn::Engine
|
6
|
+
|
7
|
+
attr_reader :apps
|
8
|
+
|
9
|
+
def initialize(dir=nil)
|
10
|
+
super(dir, "padrino", {:debug=>false})
|
11
|
+
@apps = detect_apps
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_sinatra_version
|
15
|
+
self.connected_gems.each do |gem|
|
16
|
+
return gem[:version] if gem[:name] == "sinatra"
|
17
|
+
end
|
18
|
+
|
19
|
+
return ""
|
20
|
+
end
|
21
|
+
def detect_apps
|
22
|
+
|
23
|
+
apps_rb = File.join(@target, "config", "apps.rb")
|
24
|
+
return nil unless File.exist?(apps_rb)
|
25
|
+
lines = File.readlines(apps_rb)
|
26
|
+
p = RubyParser.new
|
27
|
+
apps = []
|
28
|
+
|
29
|
+
lines.each do |line|
|
30
|
+
if /^Padrino\.mount/ =~ line
|
31
|
+
|
32
|
+
begin
|
33
|
+
tree = p.parse(line)
|
34
|
+
if ! tree.nil? && tree.sexp_type == :call
|
35
|
+
body_a = tree.sexp_body.to_a
|
36
|
+
debug_me("BODY_A=#{body_a[0]} - BODY_A_SIZE=#{body_a[0].size}")
|
37
|
+
debug_me("IS_MOUNT_CALL? #{is_mount_call?(body_a[0])}")
|
38
|
+
mp = body_a[2][1]
|
39
|
+
debug_me("MP = #{mp}")
|
40
|
+
|
41
|
+
# Padrino.mount('HelloWorldPadrino::App', :app_file => Padrino.root('app/app.rb')).to('/')
|
42
|
+
sinatra_app_rb = body_a[0][4][2][3][1] if body_a[0].size == 5 && is_mount_call?(body_a[0])
|
43
|
+
|
44
|
+
# Padrino.mount("HelloWorldPadrino:App").to('/')
|
45
|
+
if body_a[0].size == 4
|
46
|
+
|
47
|
+
# Defaulting the application name if mount point is /
|
48
|
+
sinatra_app_rb = "app/app.rb" if mp == "/"
|
49
|
+
|
50
|
+
# Take the app name as mountpoint/app.rb
|
51
|
+
sinatra_app_rb = body_a[0][3][1].downcase+"/app.rb" unless mp == "/"
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
target = File.dirname(sinatra_app_rb )
|
56
|
+
apps << Codesake::Dawn::Sinatra.new(target, mp)
|
57
|
+
end
|
58
|
+
rescue Racc::ParseError => e
|
59
|
+
debug_me(e.message)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# if line.start_with?("Padrino.mount")
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
debug_me("sinatra version is: #{self.get_sinatra_version}")
|
70
|
+
apps.each do |a|
|
71
|
+
debug_me("detected sinatra application at #{a.mount_point} ")
|
72
|
+
end
|
73
|
+
apps
|
74
|
+
end
|
75
|
+
|
76
|
+
def is_mount_call?(a)
|
77
|
+
return (a[0] == :call && a[1] == [:const, :Padrino] && a[2] == :mount)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
module Codesake
|
2
|
+
module Dawn
|
3
|
+
class Reporter
|
4
|
+
|
5
|
+
def initialize(options={})
|
6
|
+
@engine = nil
|
7
|
+
@ret = false
|
8
|
+
|
9
|
+
@filename = options[:filename]
|
10
|
+
@ret = options[:apply_all_code] unless options[:apply_all_code].nil?
|
11
|
+
@format = options[:format] unless options[:format].nil?
|
12
|
+
@engine = options[:engine] unless options[:engine].nil?
|
13
|
+
|
14
|
+
@format = :console unless is_valid_format?(@format)
|
15
|
+
end
|
16
|
+
|
17
|
+
def report
|
18
|
+
ascii_tabular_report if @format == :tabular
|
19
|
+
json_report if @format == :json
|
20
|
+
ascii_plain_report if @format == :console
|
21
|
+
html_report if @format == :html
|
22
|
+
end
|
23
|
+
private
|
24
|
+
|
25
|
+
def write(output)
|
26
|
+
|
27
|
+
puts output if @filename.nil?
|
28
|
+
|
29
|
+
unless @filename.nil?
|
30
|
+
$logger.warn "I will use codesake.css, bootstrap.min.css and bootstrap.js stored in ./support/ directory" if @format == :html
|
31
|
+
File.open(@filename, "w") do |f|
|
32
|
+
f.puts output
|
33
|
+
end
|
34
|
+
$logger.ok "#{@filename} created (#{output.length} bytes)"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def is_valid_format?(format)
|
38
|
+
return false if format.nil?
|
39
|
+
return true if (format == :console) || (format == :tabular) || (format == :json) || (format == :html) || (format == :csv)
|
40
|
+
return false # otherwise
|
41
|
+
end
|
42
|
+
|
43
|
+
def html_report
|
44
|
+
html_head = "<!doctype html>\n<html>\n<head>\n<title>Codesake::Dawn report for #{File.basename(@engine.target)}</title>"
|
45
|
+
html_head += "<script src=\"./support/bootstrap.js\"></script>\n"
|
46
|
+
html_head += "<link href=\"./support/codesake.css\" media=\"all\" rel=\"stylesheet\" />\n"
|
47
|
+
html_head += "<link href=\"./support/bootstrap.min.css\" media=\"all\" rel=\"stylesheet\" />\n"
|
48
|
+
html_head += "</head>\n"
|
49
|
+
html_body = "<body>\n"
|
50
|
+
html_body += ""
|
51
|
+
html_body += "<div id=\"wrap\">\n"
|
52
|
+
html_body += "<div class=\"container-narrow\">\n"
|
53
|
+
html_body += "<div class=\"masthead\">\n"
|
54
|
+
html_body += "<ul class=\"nav nav-pills pull-right\">\n"
|
55
|
+
html_body += "<li class=\"\"><a href=\"https://dawn.codesake.com\">Home</a></li>\n"
|
56
|
+
html_body += "<li class=\"active\"><a href=\"https://github.com/codesake/codesake-dawn\">Github repo</a></li>\n"
|
57
|
+
html_body += "</ul>\n"
|
58
|
+
html_body += "<h3 class=\"muted\">Codesake::Dawn</h3>\n"
|
59
|
+
html_body += "</div>\n"
|
60
|
+
html_body += "<h1>Security code review results for \"#{File.basename(@engine.target)}\"</h1>\n"
|
61
|
+
html_body += "<hr />\n"
|
62
|
+
html_body += "<h2>Scan detail</h2>\n"
|
63
|
+
html_body += "<div class=\"row\">\n"
|
64
|
+
html_body += "<p>The scan was last executed #{@engine.scan_start.strftime("%d %b %Y - %T")} and Codesake::Dawn founds #{@engine.count_vulnerabilities} vulnerabilities</p>\n"
|
65
|
+
html_body += "</div>\n"
|
66
|
+
html_body += "<hr />\n"
|
67
|
+
html_body += "<h2>Scan details</h2>\n"
|
68
|
+
html_body += "<table class=\"table-striped table-bordered table\">\n"
|
69
|
+
html_body += "<thead><tr><td>Key</td><td>Value</td></tr></thead>\n"
|
70
|
+
html_body += "<tbody>\n"
|
71
|
+
html_body += "<tr><td>Dawn version</td><td>#{Codesake::Dawn::VERSION}</td></tr>" unless Codesake::Dawn::RELEASE == "(development)\n"
|
72
|
+
html_body += "<tr><td>Dawn development version</td><td>#{Codesake::Dawn::VERSION}</td></tr>" if Codesake::Dawn::RELEASE == "(development)\n"
|
73
|
+
html_body += "<tr><td>Scan duration</td><td>#{@engine.scan_time.round(3)} sec</td></tr>\n"
|
74
|
+
html_body += "<tr><td>Target</td><td>#{@engine.target}</td></tr>\n"
|
75
|
+
html_body += "<tr><td>MVC detected framework</td><td>#{@engine.name} v#{@engine.get_mvc_version}</td></tr>" unless @engine.name == "Gemfile.lock\n"
|
76
|
+
html_body += "<tr><td>MVC detected framework</td><td>#{@engine.force} v#{@engine.get_mvc_version}</td></tr>" if @engine.name == "Gemfile.lock\n"
|
77
|
+
if @ret
|
78
|
+
html_body += "<tr><td>Applied checks</td><td>#{@engine.applied_checks} security checks</td></tr>\n"
|
79
|
+
html_body += "<tr><td>Skipped checks</td><td>#{@engine.skipped_checks} security checks</td></tr>\n"
|
80
|
+
else
|
81
|
+
html_body += "<tr><td>Applied checks</td><td>No security checks in the knowledge base</td></tr>\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
html_body+="<tr><td>Vulnerabilities found</td><td>#{@engine.count_vulnerabilities}</td></tr>\n"
|
85
|
+
html_body+="<tr><td>Mitigated issues found</td><td>#{@engine.mitigated_issues.count}</td></tr>\n"
|
86
|
+
html_body+="<tr><td>Reflected XSS</td><td>#{@engine.reflected_xss.count}</td></tr>\n"
|
87
|
+
html_body += "</tbody>\n"
|
88
|
+
html_body += "</table>\n"
|
89
|
+
|
90
|
+
|
91
|
+
if @engine.count_vulnerabilities > 0
|
92
|
+
html_body += "<hr />\n"
|
93
|
+
html_body += "<h2>Vulnerabilities found</h2>\n"
|
94
|
+
html_body += "<table class=\"table-striped table-bordered table\">\n"
|
95
|
+
html_body += "<thead><tr><td>Name</td><td>Severity</td><td>Priority</td><td>CVSS score</td><td>Description</td><td>Remediation</td></tr></thead>\n"
|
96
|
+
|
97
|
+
@engine.vulnerabilities.each do |vuln|
|
98
|
+
html_body += "<tr><td><a href=\"#{vuln[:cve_link]}\">#{vuln[:name]}</a></td><td>#{vuln[:severity]}</td><td>#{vuln[:priority]}</td><td>#{vuln[:cvss_score]}</td><td>#{vuln[:message]}</td><td>#{vuln[:remediation]}</td></tr>\n"
|
99
|
+
end
|
100
|
+
html_body += "</tbody>\n"
|
101
|
+
html_body += "</table>\n"
|
102
|
+
end
|
103
|
+
html_body += "<div id=\"push\"></div>\n"
|
104
|
+
html_body += "<div id=\"footer\">\n"
|
105
|
+
html_body += "<div class=\"container\">\n"
|
106
|
+
html_body += "<p class=\"muted credit\">© <a href=\"http://dawn.codesake.com\">Codesake::Dawn</a> — #{Time.now.strftime("%Y")} — engine v#{Codesake::Dawn::VERSION} (#{Codesake::Dawn::RELEASE})</p>\n"
|
107
|
+
html_body += "</div>\n"
|
108
|
+
html_body += "</div>\n"
|
109
|
+
html_body += "</div>\n"
|
110
|
+
html_body += "</div>\n"
|
111
|
+
|
112
|
+
html_body += "</body>\n"
|
113
|
+
html_body += "</html>"
|
114
|
+
|
115
|
+
|
116
|
+
html = html_head + html_body
|
117
|
+
|
118
|
+
write(html)
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def ascii_tabular_report
|
123
|
+
|
124
|
+
# 0_First table: executive summary
|
125
|
+
rows = []
|
126
|
+
rows << ['Dawn version', Codesake::Dawn::VERSION] unless Codesake::Dawn::RELEASE == "(development)"
|
127
|
+
rows << ['Dawn development version', Codesake::Dawn::VERSION] if Codesake::Dawn::RELEASE == "(development)"
|
128
|
+
rows << ['Scan started', @engine.scan_start]
|
129
|
+
rows << ['Scan duration', "#{@engine.scan_time.round(3)} sec"]
|
130
|
+
rows << ['Target', @engine.target]
|
131
|
+
rows << ['MVC detected framework', "#{@engine.name} v#{@engine.get_mvc_version}" ] unless @engine.name == "Gemfile.lock"
|
132
|
+
rows << ['MVC detected framework', "#{@engine.force} v#{@engine.get_mvc_version}" ] if @engine.name == "Gemfile.lock"
|
133
|
+
if @ret
|
134
|
+
rows << ['Applied checks', "#{@engine.applied_checks} security checks"]
|
135
|
+
rows << ['Skipped checks', "#{@engine.skipped_checks} security checks"]
|
136
|
+
else
|
137
|
+
rows << ['Applied checks', "No security checks in the knowledge base"]
|
138
|
+
end
|
139
|
+
rows << ['Vulnerabilities found', @engine.count_vulnerabilities]
|
140
|
+
rows << ['Mitigated issues found', @engine.mitigated_issues.count]
|
141
|
+
rows << ['Reflected XSS', @engine.reflected_xss.count]
|
142
|
+
table = Terminal::Table.new :title=>'Scan summary', :rows => rows
|
143
|
+
puts table
|
144
|
+
|
145
|
+
|
146
|
+
if @engine.count_vulnerabilities > 0
|
147
|
+
|
148
|
+
# 1_Vulnerabilities
|
149
|
+
rows = []
|
150
|
+
@engine.vulnerabilities.each do |vuln|
|
151
|
+
rows << [vuln[:name].justify(10), vuln[:severity], vuln[:priority], vuln[:message].justify(50), vuln[:remediation].justify(15), vuln[:evidences].join.justify(15)]
|
152
|
+
rows << :separator
|
153
|
+
end
|
154
|
+
table = Terminal::Table.new :title=>"Vulnerabilities", :headings=>['Issue', 'Severity', 'Priority', 'Description', 'Solution', 'Evidences'], :rows=>rows
|
155
|
+
puts table
|
156
|
+
|
157
|
+
rows = []
|
158
|
+
if @engine.has_reflected_xss?
|
159
|
+
@engine.reflected_xss.each do |vuln|
|
160
|
+
rows << [vuln[:sink_source], vuln[:sink_view], "#{vuln[:sink_file]}@#{vuln[:sink_line]}",vuln[:sink_evidence]]
|
161
|
+
rows << :separator
|
162
|
+
end
|
163
|
+
table = Terminal::Table.new :title=>"Reflected Cross Site Scripting", :headings=>['Sink name', 'View', 'Location the sink was read', 'Evidences'], :rows=>rows
|
164
|
+
puts table
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
if @engine.mitigated_issues.count > 0
|
171
|
+
# 2_Mitigated issues
|
172
|
+
rows = []
|
173
|
+
@engine.mitigated_issues.each do |vuln|
|
174
|
+
rows << [vuln[:name].justify(10), vuln[:message].justify(50), vuln[:evidences].join.justify(15)]
|
175
|
+
rows << :separator
|
176
|
+
end
|
177
|
+
table = Terminal::Table.new :title=>"Mitigated issues", :headings=>['Issue', 'Description', 'Evidences'], :rows=>rows
|
178
|
+
puts table
|
179
|
+
end
|
180
|
+
|
181
|
+
true
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
def json_report
|
186
|
+
result = {}
|
187
|
+
return {:status=>"KO", :message=>"BUG at #{__FILE__}@#{__LINE__}: target is empty or engine is nil."}.to_json if @engine.target.empty? or @engine.nil?
|
188
|
+
return {:status=>"KO", :message=>"#{target} doesn't exist"}.to_json if ! Dir.exist?(@engine.target)
|
189
|
+
return {:status=>"KO", :message=>"no security checks applied"}.to_json unless @ret
|
190
|
+
|
191
|
+
result[:status]="OK"
|
192
|
+
result[:dawn_version] = Codesake::Dawn::VERSION
|
193
|
+
result[:dawn_status] = "Develoment version" if Codesake::Dawn::RELEASE == "(development)"
|
194
|
+
result[:scan_started] = @engine.scan_start
|
195
|
+
result[:scan_duration] = "#{@engine.scan_time.round(3)} sec"
|
196
|
+
result[:target]=@engine.target
|
197
|
+
result[:mvc]=@engine.name unless @engine.name == "Gemfile.lock"
|
198
|
+
result[:mvc]=@engine.force if @engine.name == "Gemfile.lock"
|
199
|
+
result[:mvc_version]=@engine.get_mvc_version
|
200
|
+
|
201
|
+
result[:applied_checks_count] = @engine.applied_checks
|
202
|
+
result[:skipped_checks_count] = @engine.skipped_checks
|
203
|
+
result[:vulnerabilities_count]=@engine.count_vulnerabilities
|
204
|
+
|
205
|
+
result[:mitigated_issues_count] = @engine.mitigated_issues.count
|
206
|
+
result[:reflected_xss_count] = @engine.reflected_xss.count
|
207
|
+
result[:vulnerabilities]=[]
|
208
|
+
@engine.vulnerabilities.each do |v|
|
209
|
+
result[:vulnerabilities] << {
|
210
|
+
:name => v[:name],
|
211
|
+
:cve_link => v[:cve_link],
|
212
|
+
:severity => v[:severity],
|
213
|
+
:priority => v[:priority],
|
214
|
+
:cvss_score => v[:cvss_score],
|
215
|
+
:message => v[:message],
|
216
|
+
:remediation => v[:remediation]
|
217
|
+
}
|
218
|
+
end
|
219
|
+
result[:mitigated_vuln] = @engine.mitigated_issues
|
220
|
+
result[:reflected_xss] = []
|
221
|
+
@engine.reflected_xss.each do |r|
|
222
|
+
result[:reflected_xss] << "request parameter \"#{r[:sink_source]}\""
|
223
|
+
end
|
224
|
+
|
225
|
+
write(result.to_json)
|
226
|
+
true
|
227
|
+
end
|
228
|
+
|
229
|
+
def ascii_plain_report
|
230
|
+
|
231
|
+
$logger.log "scanning #{@engine.target}"
|
232
|
+
$logger.log "#{@engine.name} v#{@engine.get_mvc_version} detected" unless @engine.name == "Gemfile.lock"
|
233
|
+
$logger.log "#{@engine.force} v#{@engine.get_mvc_version} detected" if @engine.name == "Gemfile.lock"
|
234
|
+
$logger.log "applying all security checks"
|
235
|
+
if @ret
|
236
|
+
$logger.log "#{@engine.applied_checks} security checks applied - #{@engine.skipped_checks} security checks skipped"
|
237
|
+
else
|
238
|
+
$logger.err "no security checks in the knowledge base"
|
239
|
+
end
|
240
|
+
|
241
|
+
if @engine.count_vulnerabilities != 0
|
242
|
+
$logger.log "#{@engine.count_vulnerabilities} vulnerabilities found"
|
243
|
+
@engine.vulnerabilities.each do |vuln|
|
244
|
+
$logger.err "#{vuln[:name]} check failed"
|
245
|
+
$logger.log "Severity: #{vuln[:severity]}"
|
246
|
+
$logger.log "Priority: #{vuln[:priority]}"
|
247
|
+
$logger.log "Description: #{vuln[:message]}"
|
248
|
+
$logger.log "Solution: #{vuln[:remediation]}"
|
249
|
+
$logger.log "Evidence:"
|
250
|
+
vuln[:evidences].each do |evidence|
|
251
|
+
$logger.log "\t#{evidence}"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
if @engine.has_reflected_xss?
|
255
|
+
$logger.log "#{@engine.reflected_xss.count} reflected XSS found"
|
256
|
+
@engine.reflected_xss.each do |vuln|
|
257
|
+
$logger.log "request parameter \"#{vuln[:sink_source]}\" is used without escaping in #{vuln[:sink_view]}. It was read here: #{vuln[:sink_file]}@#{vuln[:sink_line]}"
|
258
|
+
$logger.err "evidence: #{vuln[:sink_evidence]}"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
else
|
263
|
+
$logger.ok "no vulnerabilities found."
|
264
|
+
end
|
265
|
+
|
266
|
+
if @engine.mitigated_issues.count != 0
|
267
|
+
$logger.log "#{@engine.mitigated_issues.count} mitigated vulnerabilities found"
|
268
|
+
@engine.mitigated_issues.each do |vuln|
|
269
|
+
$logger.ok "#{vuln[:name]} mitigated"
|
270
|
+
vuln[:evidences].each do |evidence|
|
271
|
+
$logger.err evidence
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
true
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require "codesake/dawn/engine"
|
2
|
+
require 'ruby_parser'
|
3
|
+
|
4
|
+
module Codesake
|
5
|
+
module Dawn
|
6
|
+
class Sinatra
|
7
|
+
include Codesake::Dawn::Engine
|
8
|
+
|
9
|
+
attr_reader :sinks
|
10
|
+
attr_reader :appname
|
11
|
+
|
12
|
+
# mount_point is the mounting point for this Sinatra application. It's
|
13
|
+
# filled up only in padrino engines
|
14
|
+
attr_reader :mount_point
|
15
|
+
|
16
|
+
def initialize(dir=nil, mp=nil)
|
17
|
+
super(dir, "sinatra")
|
18
|
+
@appname = detect_appname(self.target)
|
19
|
+
error! if self.appname == ""
|
20
|
+
@views = detect_views
|
21
|
+
@sinks = detect_sinks(self.appname) unless self.appname == ""
|
22
|
+
@reflected_xss = detect_reflected_xss unless self.appname == "" || !@views
|
23
|
+
@mount_point = (mp.nil?)? "" : mp
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO: appname should be hopefully autodetect from config.ru
|
27
|
+
def detect_appname(target)
|
28
|
+
return "app.rb" if File.exist?(File.join(self.target, "app.rb"))
|
29
|
+
return "application.rb" if File.exist?(File.join(self.target, "application.rb"))
|
30
|
+
file_array = Dir.glob(File.join("#{target}", "*.rb"))
|
31
|
+
return file_array[0] if ! file_array.nil? and file_array.count == 1
|
32
|
+
return "" # gracefully failure
|
33
|
+
end
|
34
|
+
|
35
|
+
def detect_reflected_xss
|
36
|
+
ret = []
|
37
|
+
@views.each do |v|
|
38
|
+
view_content = File.read(v[:filename])
|
39
|
+
@sinks.each do |sink|
|
40
|
+
if view_content.match(sink[:sink_name])
|
41
|
+
sink[:sink_view] = v[:filename]
|
42
|
+
ret << sink
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
ret
|
47
|
+
end
|
48
|
+
|
49
|
+
def detect_sinks(appname=nil)
|
50
|
+
ret = []
|
51
|
+
appname = "app.rb" if appname.nil? and self.appname == ""
|
52
|
+
app_rb = File.readlines(File.join(self.target, appname)) if File.exist?(File.join(self.target, appname))
|
53
|
+
return [] if app_rb.nil?
|
54
|
+
|
55
|
+
parser = RubyParser.new
|
56
|
+
|
57
|
+
app_rb.each_with_index do |line, i|
|
58
|
+
line = line.chomp
|
59
|
+
|
60
|
+
unless line.match(/params/).nil?
|
61
|
+
|
62
|
+
begin
|
63
|
+
t = parser.parse(line)
|
64
|
+
|
65
|
+
# a[1] = params["foo"]
|
66
|
+
#
|
67
|
+
if (! t.nil? and t.sexp_type == :attrasgn)
|
68
|
+
body = t.sexp_body.to_a
|
69
|
+
|
70
|
+
if is_assignement_from_params?(body, :attrasgn)
|
71
|
+
|
72
|
+
if body[0][0] == :call
|
73
|
+
sink_name=body[0][2].to_s unless body[1].to_s == "[]="
|
74
|
+
sink_name="#{body[2].to_a[1].to_s}" if body[1].to_s == "[]=" # the sink is assigned to an Array
|
75
|
+
|
76
|
+
sink_source = "#{body[3].to_a[1][2].to_s}[#{body[3].to_a[3][1].to_s}]"
|
77
|
+
|
78
|
+
ret << {:sink_name=>sink_name, :sink_kind=>:params, :sink_line=>i+1, :sink_source=>sink_source, :sink_file=>appname, :sink_evidence=>line}
|
79
|
+
end
|
80
|
+
if body[0][0] == :ivar
|
81
|
+
sink_name=body[0][1].to_s
|
82
|
+
sink_pos=body[2][1].to_i
|
83
|
+
sink_source=body[3][3][1]
|
84
|
+
|
85
|
+
ret << {:sink_name=>sink_name, :sink_kind=>:params, :sink_line=>i+1, :sink_source=>sink_source, :sink_file=>appname, :sink_evidence=>line}
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# a = params["foo"]
|
92
|
+
if (! t.nil? and t.sexp_type == :iasgn)
|
93
|
+
body = t.sexp_body.to_a
|
94
|
+
if is_assignement_from_params?(body, :iasgn)
|
95
|
+
sink_name = body[0].to_s
|
96
|
+
sink_source = "#{body[1][3][1].to_s}"
|
97
|
+
ret << {:sink_name=>sink_name, :sink_kind=>:params, :sink_line=>i+1, :sink_source=>sink_source, :sink_file=>appname, :sink_evidence=>line}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
rescue Racc::ParseError => e
|
101
|
+
# TODO: we must pass logger instance to engines if we want some error message
|
102
|
+
# For now... silently discard parse errors
|
103
|
+
return []
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
ret
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def is_assignement_from_params?(body, kind)
|
114
|
+
return ( ! body[3].nil? and body[3].to_a[1][2].to_s == "params") if kind == :attrasgn
|
115
|
+
return ( ! body[1].nil? and ! body[1][1].nil? and body[1][1][2].to_s == "params") if kind == :iasgn
|
116
|
+
end
|
117
|
+
|
118
|
+
def detect_views
|
119
|
+
return build_view_array(File.join(self.target, "views")) if File.exist?(File.join(self.target, "views"))
|
120
|
+
[]
|
121
|
+
end
|
122
|
+
|
123
|
+
# e = Haml::Engine.new(File.read(template))
|
124
|
+
# e.precompiled and grep for format_script
|
125
|
+
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|