16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/necropsy/entry_points/plain.rb', line 16
def apply(graph, project)
graph.nodes.values.select { |node| node.kind == :block_entry && !node.test }.each do |node|
pattern = SCRIPT_PATTERNS.find { |candidate| File.fnmatch?(candidate, node.file, File::FNM_PATHNAME) }
next unless pattern
graph.add_entry_point(
node.graph_id,
:main_script,
domain: :runtime,
evidence: { 'type' => 'path_policy', 'pattern' => pattern, 'file' => node.file }
)
end
project.config.entry_point_patterns.each do |pattern|
graph.nodes.each_value do |node|
next if node.test
next unless File.fnmatch?(pattern, node.symbol_id)
graph.add_entry_point(
node.graph_id,
:public_api_declared,
domain: project.config.library_world? ? :external : :runtime,
evidence: { 'type' => 'configured_pattern', 'pattern' => pattern }
)
end
end
return if project.config.library_world?
api_files = primary_library_files(project)
graph.method_nodes.each do |node|
next unless api_files.include?(node.file)
next unless node.kind == :singleton_method && node.visibility == :public
graph.add_entry_point(
node.graph_id,
:public_api_declared,
domain: :runtime,
evidence: { 'type' => 'gem_entry_file', 'file' => node.file }
)
end
end
|