Skip to content

Commit 5349c7f

Browse files
authored
Merge pull request #223 from noir-cr/dev
Release v0.12.1
2 parents 56cb947 + a7ab5fe commit 5349c7f

File tree

11 files changed

+149
-18
lines changed

11 files changed

+149
-18
lines changed

.ameba.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ Metrics/CyclomaticComplexity:
66
MaxComplexity: 40
77
Enabled: true
88
Severity: Warning
9+
10+
Lint/RedundantWithIndex:
11+
Enabled: false
12+
13+
Lint/UnusedArgument:
14+
Excluded:
15+
- "src/analyzer/analyzers/analyzer_example.cr"

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,22 @@ Usage: noir <flags>
9797
9898
Output:
9999
-f FORMAT, --format json Set output format
100-
[plain/json/yaml/markdown-table/curl/httpie/oas2/oas3]
100+
* plain yaml json jsonl markdown-table
101+
* curl httpie oas2 oas3
102+
* only-url only-param only-header only-cookie
101103
-o PATH, --output out.txt Write result to file
102104
--set-pvalue VALUE Specifies the value of the identified parameter
103105
--include-path Include file path in the plain result
104106
--no-color Disable color output
105107
--no-log Displaying only the results
106108
107109
Deliver:
108-
--send-req Send the results to the web request
109-
--send-proxy http://proxy.. Send the results to the web request via http proxy
110-
--send-es http://es.. Send the results to elasticsearch
111-
--with-headers X-Header:Value Add Custom Headers to be Used in Deliver
112-
--use-matchers string Delivers URLs that match a specific condition
113-
--use-filters string Excludes URLs that match a specific condition
110+
--send-req Send results to a web request
111+
--send-proxy http://proxy.. Send results to a web request via an HTTP proxy
112+
--send-es http://es.. Send results to Elasticsearch
113+
--with-headers X-Header:Value Add custom headers to be included in the delivery
114+
--use-matchers string Send URLs that match specific conditions to the Deliver
115+
--use-filters string Exclude URLs that match specified conditions and send the rest to Deliver
114116
115117
Technologies:
116118
-t TECHS, --techs rails,php Specify the technologies to use

shard.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: noir
2-
version: 0.12.0
2+
version: 0.12.1
33

44
authors:
55
- hahwul <hahwul@gmail.com>
6+
- ksg97031 <ksg97031@gmail.com>
67

78
targets:
89
noir:

spec/unit_test/models/output_builder_spec.cr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,29 @@ describe "Initialize" do
4141
object = OutputBuilderOas3.new options
4242
object.output_file.should eq("output.json")
4343
end
44+
45+
it "OutputBuilderOnlyUrl" do
46+
object = OutputBuilderOnlyUrl.new options
47+
object.output_file.should eq("output.json")
48+
end
49+
50+
it "OutputBuilderOnlyParam" do
51+
object = OutputBuilderOnlyParam.new options
52+
object.output_file.should eq("output.json")
53+
end
54+
55+
it "OutputBuilderOnlyHeader" do
56+
object = OutputBuilderOnlyHeader.new options
57+
object.output_file.should eq("output.json")
58+
end
59+
60+
it "OutputBuilderOnlyCookie" do
61+
object = OutputBuilderOnlyCookie.new options
62+
object.output_file.should eq("output.json")
63+
end
64+
65+
it "OutputBuilderJsonl" do
66+
object = OutputBuilderJsonl.new options
67+
object.output_file.should eq("output.json")
68+
end
4469
end

src/models/noir.cr

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,13 @@ class NoirRunner
154154

155155
def report
156156
case options[:format]
157-
when "json"
158-
puts @endpoints.to_json
159157
when "yaml"
160158
puts @endpoints.to_yaml
159+
when "json"
160+
puts @endpoints.to_json
161+
when "jsonl"
162+
builder = OutputBuilderJsonl.new @options
163+
builder.print @endpoints
161164
when "markdown-table"
162165
builder = OutputBuilderMarkdownTable.new @options
163166
builder.print @endpoints
@@ -173,6 +176,18 @@ class NoirRunner
173176
when "oas3"
174177
buidler = OutputBuilderOas3.new @options
175178
buidler.print @endpoints
179+
when "only-url"
180+
builder = OutputBuilderOnlyUrl.new @options
181+
builder.print @endpoints
182+
when "only-param"
183+
builder = OutputBuilderOnlyParam.new @options
184+
builder.print @endpoints
185+
when "only-header"
186+
builder = OutputBuilderOnlyHeader.new @options
187+
builder.print @endpoints
188+
when "only-cookie"
189+
builder = OutputBuilderOnlyCookie.new @options
190+
builder.print @endpoints
176191
else
177192
builder = OutputBuilderCommon.new @options
178193
builder.print @endpoints

src/noir.cr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require "./options.cr"
66
require "./techs/techs.cr"
77

88
module Noir
9-
VERSION = "0.12.0"
9+
VERSION = "0.12.1"
1010
end
1111

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

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

23-
parser.on "-f FORMAT", "--format json", "Set output format \n[plain/json/yaml/markdown-table/curl/httpie/oas2/oas3]" { |var| noir_options[:format] = var }
23+
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 }
2424
parser.on "-o PATH", "--output out.txt", "Write result to file" { |var| noir_options[:output] = var }
2525
parser.on "--set-pvalue VALUE", "Specifies the value of the identified parameter" { |var| noir_options[:set_pvalue] = var }
2626
parser.on "--include-path", "Include file path in the plain result" do
@@ -34,16 +34,16 @@ OptionParser.parse do |parser|
3434
end
3535

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

src/output_builder/jsonl.cr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "../models/output_builder"
2+
require "../models/endpoint"
3+
4+
class OutputBuilderJsonl < OutputBuilder
5+
def print(endpoints : Array(Endpoint))
6+
endpoints.each do |endpoint|
7+
ob_puts endpoint.to_json
8+
end
9+
end
10+
end

src/output_builder/only-cookie.cr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "../models/output_builder"
2+
require "../models/endpoint"
3+
4+
class OutputBuilderOnlyCookie < OutputBuilder
5+
def print(endpoints : Array(Endpoint))
6+
cookies = [] of String
7+
endpoints.each do |endpoint|
8+
endpoint.params.each do |param|
9+
if param.param_type == "cookie"
10+
cookies << param.name
11+
end
12+
end
13+
end
14+
15+
cookies.uniq.each do |cookie|
16+
puts cookie.colorize(:light_green).toggle(@is_color)
17+
end
18+
end
19+
end

src/output_builder/only-header.cr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "../models/output_builder"
2+
require "../models/endpoint"
3+
4+
class OutputBuilderOnlyHeader < OutputBuilder
5+
def print(endpoints : Array(Endpoint))
6+
headers = [] of String
7+
endpoints.each do |endpoint|
8+
endpoint.params.each do |param|
9+
if param.param_type == "header"
10+
headers << param.name
11+
end
12+
end
13+
end
14+
15+
headers.uniq.each do |header|
16+
puts header.colorize(:light_green).toggle(@is_color)
17+
end
18+
end
19+
end

src/output_builder/only-param.cr

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require "../models/output_builder"
2+
require "../models/endpoint"
3+
4+
class OutputBuilderOnlyParam < OutputBuilder
5+
def print(endpoints : Array(Endpoint))
6+
common_params = [] of String
7+
targets = ["query", "json", "form"]
8+
9+
endpoints.each do |endpoint|
10+
endpoint.params.each do |param|
11+
if targets.includes? param.param_type
12+
common_params << param.name
13+
end
14+
end
15+
end
16+
17+
common_params.uniq.each do |common_param|
18+
puts common_param.colorize(:light_green).toggle(@is_color)
19+
end
20+
end
21+
end

src/output_builder/only-url.cr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require "../models/output_builder"
2+
require "../models/endpoint"
3+
4+
class OutputBuilderOnlyUrl < OutputBuilder
5+
def print(endpoints : Array(Endpoint))
6+
endpoints.each do |endpoint|
7+
baked = bake_endpoint(endpoint.url, endpoint.params)
8+
r_url = baked[:url].colorize(:light_yellow).toggle(@is_color)
9+
ob_puts "#{r_url}"
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)