Sha256: 0571007bcf925e4a8f15ec07e26187611337b42241b0cc9bd85fa5e2398a4e91
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require 'sinatra' require 'json' REPORT_PATH = ARGV[0] unless REPORT_PATH puts "usage: ruby application.rb path/to/report.json" exit(1) end unless File.exist?(REPORT_PATH) puts "Cannot open report file: #{REPORT_PATH}" exit(1) end helpers do def prepare_inputs(warning) warning['inputs'].sort_by { |value, input| -input['reported_at'] } end def highlight_input(input, tag) return input[0...100] unless tag value = tag['value'] source = tag['source'] input = input.gsub(value) { |match| '[TAINTED_LOVE_MATCH_START]' + match + '[TAINTED_LOVE_MATCH_END]' } h(input) .gsub('[TAINTED_LOVE_MATCH_START]', '<span data-title="' + h(source) + '">') .gsub('[TAINTED_LOVE_MATCH_END]', '</span>') end def h(text) Rack::Utils.escape_html(text) end def render_source(file, line) File.read(file).lines.each.with_index.drop(line - 2).take(3).to_a end end get '/' do @report = JSON.parse(File.read(REPORT_PATH)) @warnings = @report['warnings'].sort_by do |_, code_path| -code_path['inputs'].map { |value, input| input['reported_at'] }.max end.to_h erb :index end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tainted_love-0.4.1 | tools/web/application.rb |
tainted_love-0.4.0 | tools/web/application.rb |