Skip to content

Commit b9f0452

Browse files
committed
feat(analyzer): add support for ZAP Sites Tree specification analysis
Signed-off-by: HAHWUL <hahwul@gmail.com>
1 parent cf1dda3 commit b9f0452

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/analyzer/analyzer.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ def initialize_analyzers(logger : NoirLogger)
3333
{"kotlin_spring", Kotlin::Spring},
3434
{"oas2", Specification::Oas2},
3535
{"oas3", Specification::Oas3},
36+
{"raml", Specification::RAML},
37+
{"zap_sites_tree", Specification::ZapSitesTree},
3638
{"php_pure", Php::Php},
3739
{"python_django", Python::Django},
3840
{"python_fastapi", Python::FastAPI},
3941
{"python_flask", Python::Flask},
40-
{"raml", Specification::RAML},
4142
{"ruby_hanami", Ruby::Hanami},
4243
{"ruby_rails", Ruby::Rails},
4344
{"ruby_sinatra", Ruby::Sinatra},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require "../../../models/analyzer"
2+
3+
module Analyzer::Specification
4+
class ZapSitesTree < Analyzer
5+
def analyze
6+
locator = CodeLocator.instance
7+
sites_trees = locator.all("zap-sites-tree")
8+
9+
if sites_trees.is_a?(Array(String))
10+
sites_trees.each do |sites_tree|
11+
if File.exists?(sites_tree)
12+
details = Details.new(PathInfo.new(sites_tree))
13+
content = File.read(sites_tree, encoding: "utf-8", invalid: :skip)
14+
json_obj = JSON.parse(content)
15+
16+
begin
17+
children = json_obj["children"].as_h
18+
if children.size > 0
19+
process_node(children)
20+
end
21+
rescue e
22+
@logger.debug "Exception of #{sites_tree}/paths"
23+
@logger.debug_sub e
24+
end
25+
end
26+
end
27+
end
28+
29+
@result
30+
end
31+
32+
def process_node(children)
33+
# TODO..
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)