Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.12.1 #223

Merged
merged 13 commits into from
Jan 12, 2024
7 changes: 7 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ Metrics/CyclomaticComplexity:
MaxComplexity: 40
Enabled: true
Severity: Warning

Lint/RedundantWithIndex:
Enabled: false

Lint/UnusedArgument:
Excluded:
- "src/analyzer/analyzers/analyzer_example.cr"
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,22 @@ Usage: noir <flags>

Output:
-f FORMAT, --format json Set output format
[plain/json/yaml/markdown-table/curl/httpie/oas2/oas3]
* plain yaml json jsonl markdown-table
* curl httpie oas2 oas3
* only-url only-param only-header only-cookie
-o PATH, --output out.txt Write result to file
--set-pvalue VALUE Specifies the value of the identified parameter
--include-path Include file path in the plain result
--no-color Disable color output
--no-log Displaying only the results

Deliver:
--send-req Send the results to the web request
--send-proxy http://proxy.. Send the results to the web request via http proxy
--send-es http://es.. Send the results to elasticsearch
--with-headers X-Header:Value Add Custom Headers to be Used in Deliver
--use-matchers string Delivers URLs that match a specific condition
--use-filters string Excludes URLs that match a specific condition
--send-req Send results to a web request
--send-proxy http://proxy.. Send results to a web request via an HTTP proxy
--send-es http://es.. Send results to Elasticsearch
--with-headers X-Header:Value Add custom headers to be included in the delivery
--use-matchers string Send URLs that match specific conditions to the Deliver
--use-filters string Exclude URLs that match specified conditions and send the rest to Deliver

Technologies:
-t TECHS, --techs rails,php Specify the technologies to use
Expand Down
3 changes: 2 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: noir
version: 0.12.0
version: 0.12.1

authors:
- hahwul <[email protected]>
- ksg97031 <[email protected]>

targets:
noir:
Expand Down
25 changes: 25 additions & 0 deletions spec/unit_test/models/output_builder_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,29 @@ describe "Initialize" do
object = OutputBuilderOas3.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderOnlyUrl" do
object = OutputBuilderOnlyUrl.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderOnlyParam" do
object = OutputBuilderOnlyParam.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderOnlyHeader" do
object = OutputBuilderOnlyHeader.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderOnlyCookie" do
object = OutputBuilderOnlyCookie.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderJsonl" do
object = OutputBuilderJsonl.new options
object.output_file.should eq("output.json")
end
end
19 changes: 17 additions & 2 deletions src/models/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ class NoirRunner

def report
case options[:format]
when "json"
puts @endpoints.to_json
when "yaml"
puts @endpoints.to_yaml
when "json"
puts @endpoints.to_json
when "jsonl"
builder = OutputBuilderJsonl.new @options
builder.print @endpoints
when "markdown-table"
builder = OutputBuilderMarkdownTable.new @options
builder.print @endpoints
Expand All @@ -173,6 +176,18 @@ class NoirRunner
when "oas3"
buidler = OutputBuilderOas3.new @options
buidler.print @endpoints
when "only-url"
builder = OutputBuilderOnlyUrl.new @options
builder.print @endpoints
when "only-param"
builder = OutputBuilderOnlyParam.new @options
builder.print @endpoints
when "only-header"
builder = OutputBuilderOnlyHeader.new @options
builder.print @endpoints
when "only-cookie"
builder = OutputBuilderOnlyCookie.new @options
builder.print @endpoints
else
builder = OutputBuilderCommon.new @options
builder.print @endpoints
Expand Down
16 changes: 8 additions & 8 deletions src/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "./options.cr"
require "./techs/techs.cr"

module Noir
VERSION = "0.12.0"
VERSION = "0.12.1"
end

noir_options = default_options()
Expand All @@ -20,7 +20,7 @@ OptionParser.parse do |parser|

parser.separator "\n Output:".colorize(:blue)

parser.on "-f FORMAT", "--format json", "Set output format \n[plain/json/yaml/markdown-table/curl/httpie/oas2/oas3]" { |var| noir_options[:format] = var }
parser.on "-f FORMAT", "--format json", "Set output format\n * plain yaml json jsonl markdown-table\n * curl httpie oas2 oas3\n * only-url only-param only-header only-cookie" { |var| noir_options[:format] = var }
parser.on "-o PATH", "--output out.txt", "Write result to file" { |var| noir_options[:output] = var }
parser.on "--set-pvalue VALUE", "Specifies the value of the identified parameter" { |var| noir_options[:set_pvalue] = var }
parser.on "--include-path", "Include file path in the plain result" do
Expand All @@ -34,16 +34,16 @@ OptionParser.parse do |parser|
end

parser.separator "\n Deliver:".colorize(:blue)
parser.on "--send-req", "Send the results to the web request" { |_| noir_options[:send_req] = "yes" }
parser.on "--send-proxy http://proxy..", "Send the results to the web request via http proxy" { |var| noir_options[:send_proxy] = var }
parser.on "--send-es http://es..", "Send the results to elasticsearch" { |var| noir_options[:send_es] = var }
parser.on "--with-headers X-Header:Value", "Add Custom Headers to be Used in Deliver" do |var|
parser.on "--send-req", "Send results to a web request" { |_| noir_options[:send_req] = "yes" }
parser.on "--send-proxy http://proxy..", "Send results to a web request via an HTTP proxy" { |var| noir_options[:send_proxy] = var }
parser.on "--send-es http://es..", "Send results to Elasticsearch" { |var| noir_options[:send_es] = var }
parser.on "--with-headers X-Header:Value", "Add custom headers to be included in the delivery" do |var|
noir_options[:send_with_headers] += "#{var}::NOIR::HEADERS::SPLIT::"
end
parser.on "--use-matchers string", "Delivers URLs that match a specific condition" do |var|
parser.on "--use-matchers string", "Send URLs that match specific conditions to the Deliver" do |var|
noir_options[:use_matchers] += "#{var}::NOIR::MATCHER::SPLIT::"
end
parser.on "--use-filters string", "Excludes URLs that match a specific condition" do |var|
parser.on "--use-filters string", "Exclude URLs that match specified conditions and send the rest to Deliver" do |var|
noir_options[:use_filters] += "#{var}::NOIR::FILTER::SPLIT::"
end

Expand Down
10 changes: 10 additions & 0 deletions src/output_builder/jsonl.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderJsonl < OutputBuilder
def print(endpoints : Array(Endpoint))
endpoints.each do |endpoint|
ob_puts endpoint.to_json
end
end
end
19 changes: 19 additions & 0 deletions src/output_builder/only-cookie.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderOnlyCookie < OutputBuilder
def print(endpoints : Array(Endpoint))
cookies = [] of String
endpoints.each do |endpoint|
endpoint.params.each do |param|
if param.param_type == "cookie"
cookies << param.name
end
end
end

cookies.uniq.each do |cookie|
puts cookie.colorize(:light_green).toggle(@is_color)
end
end
end
19 changes: 19 additions & 0 deletions src/output_builder/only-header.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderOnlyHeader < OutputBuilder
def print(endpoints : Array(Endpoint))
headers = [] of String
endpoints.each do |endpoint|
endpoint.params.each do |param|
if param.param_type == "header"
headers << param.name
end
end
end

headers.uniq.each do |header|
puts header.colorize(:light_green).toggle(@is_color)
end
end
end
21 changes: 21 additions & 0 deletions src/output_builder/only-param.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderOnlyParam < OutputBuilder
def print(endpoints : Array(Endpoint))
common_params = [] of String
targets = ["query", "json", "form"]

endpoints.each do |endpoint|
endpoint.params.each do |param|
if targets.includes? param.param_type
common_params << param.name
end
end
end

common_params.uniq.each do |common_param|
puts common_param.colorize(:light_green).toggle(@is_color)
end
end
end
12 changes: 12 additions & 0 deletions src/output_builder/only-url.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderOnlyUrl < OutputBuilder
def print(endpoints : Array(Endpoint))
endpoints.each do |endpoint|
baked = bake_endpoint(endpoint.url, endpoint.params)
r_url = baked[:url].colorize(:light_yellow).toggle(@is_color)
ob_puts "#{r_url}"
end
end
end
Loading