Skip to content

Commit

Permalink
Merge pull request #3 from horecoli/exclude_special_init_systems
Browse files Browse the repository at this point in the history
Exclusion of processes from verify_single_proc_tree
  • Loading branch information
taylor authored Jun 1, 2024
2 parents 3dd7229 + 13b3a47 commit 7f2fda7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: k8s_kernel_introspection
version: 1.0.1
version: 1.0.2

authors:
- William Harris <[email protected]>
Expand Down
17 changes: 9 additions & 8 deletions src/kernel_introspection/k8s.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,25 @@ module KernelIntrospection
cmdline
end

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

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

elsif current_pid == original_parent_pid && ppid != "" &&
elsif current_pid == original_parent_pid && ppid != "" &&
status_name == name

verified = verify_single_proc_tree(ppid, name, proctree)
verified = verify_single_proc_tree(ppid, name, proctree, excluded_processes)
end
end
Log.info { "verified?: #{verified}" }
Expand Down

0 comments on commit 7f2fda7

Please sign in to comment.