Skip to content

Commit 7f2fda7

Browse files
authored
Merge pull request #3 from horecoli/exclude_special_init_systems
Exclusion of processes from verify_single_proc_tree
2 parents 3dd7229 + 13b3a47 commit 7f2fda7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: k8s_kernel_introspection
2-
version: 1.0.1
2+
version: 1.0.2
33

44
authors:
55
- William Harris <[email protected]>

src/kernel_introspection/k8s.cr

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,25 @@ module KernelIntrospection
3838
cmdline
3939
end
4040

41-
def self.verify_single_proc_tree(original_parent_pid, name, proctree : Array(Hash(String, String)))
41+
def self.verify_single_proc_tree(original_parent_pid, name, proctree : Array(Hash(String, String)), excluded_processes = [] of String)
4242
Log.info { "verify_single_proc_tree pid, name: #{original_parent_pid}, #{name}" }
43-
verified = true
44-
proctree.map do | pt |
43+
verified = true
44+
proctree.each do |pt|
4545
current_pid = "#{pt["Pid"]}".strip
4646
ppid = "#{pt["PPid"]}".strip
4747
status_name = "#{pt["Name"]}".strip
4848

49-
if current_pid == original_parent_pid && ppid != "" &&
49+
if current_pid == original_parent_pid && ppid != "" &&
5050
status_name != name
51-
# todo exclude tini, init, dumbinit?, from violations
51+
if excluded_processes.includes?(status_name)
52+
next
53+
end
5254
Log.info { "top level parent (i.e. superviser -- first parent with different name): #{status_name}" }
5355
verified = false
5456

55-
elsif current_pid == original_parent_pid && ppid != "" &&
57+
elsif current_pid == original_parent_pid && ppid != "" &&
5658
status_name == name
57-
58-
verified = verify_single_proc_tree(ppid, name, proctree)
59+
verified = verify_single_proc_tree(ppid, name, proctree, excluded_processes)
5960
end
6061
end
6162
Log.info { "verified?: #{verified}" }

0 commit comments

Comments
 (0)