# frozen_string_literal: true require 'json' module PWN module Reports # This plugin generates the Static Code Anti-Pattern Matching Analysis # results within the root of a given source repo. Two files are created, # a JSON file containing all of the SAST results and an HTML file # which is essentially the UI for the JSON file. module SAST # Supported Method Parameters:: # PWN::Reports::SAST.generate( # dir_path: dir_path, # results_hash: results_hash # ) public_class_method def self.generate(opts = {}) dir_path = opts[:dir_path].to_s if File.directory?(opts[:dir_path].to_s) raise "PWN Error: Invalid Directory #{dir_path}" if dir_path.nil? results_hash = opts[:results_hash] # JSON object Completion # File.open("#{dir_path}/pwn_scan_git_source.json", 'w') do |f| # f.print(results_hash.to_json) # end File.write( "#{dir_path}/pwn_scan_git_source.json", JSON.pretty_generate(results_hash) ) html_report = %q{

~ pwn sast





Toggle Column(s):  Timestamp |  Test Case / Security Requirements |  Path |  Line#, Formatted Content, & Last Committed By |  Raw Content |  Test Case (Anti-Pattern) Filter


# Timestamp Test Case / Security Requirements Path Line#, Formatted Content, & Last Committed By Raw Content Test Case (Anti-Pattern) Filter
} File.open("#{dir_path}/pwn_scan_git_source.html", 'w') do |f| f.print(html_report) end rescue StandardError => e raise e end # Author(s):: 0day Inc. public_class_method def self.authors "AUTHOR(S): 0day Inc. " end # Display Usage for this Module public_class_method def self.help puts "USAGE: #{self}.generate( dir_path: dir_path, results_hash: results_hash ) #{self}.authors " end end end end