diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-01-31 13:38:10 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-02-10 14:34:44 +0100 |
| commit | ad871703d4fcd9ed84544dd6f5c4221aa5df5feb (patch) | |
| tree | e56c0441a09c3d6d3cd90ec9e290b9abe65f3d82 /pkg/subsystem/entity | |
| parent | 9a724c34f06b47f05b36c5292b107e9b06048667 (diff) | |
pkg/subsystem: extract subsystems from a crash list
For now, let's use a straightforward approach:
1) Extract all subsystems for each guilty path and syz reproducer.
2) If there are both parents and children in the list, remove parents.
3) Count the remaining subsystems.
4) Pick the ones that appear most often.
Diffstat (limited to 'pkg/subsystem/entity')
| -rw-r--r-- | pkg/subsystem/entity/entities.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/subsystem/entity/entities.go b/pkg/subsystem/entity/entities.go index bca218ebe..9d1d8e5a5 100644 --- a/pkg/subsystem/entity/entities.go +++ b/pkg/subsystem/entity/entities.go @@ -12,6 +12,23 @@ type Subsystem struct { Parents []*Subsystem } +// ReachableParents returns the set of subsystems reachable from the current one. +func (subsystem *Subsystem) ReachableParents() map[*Subsystem]struct{} { + ret := make(map[*Subsystem]struct{}) + var dfs func(node *Subsystem) + dfs = func(node *Subsystem) { + if _, visited := ret[node]; visited { + return + } + for _, p := range node.Parents { + ret[p] = struct{}{} + dfs(p) + } + } + dfs(subsystem) + return ret +} + // PathRule describes the part of the directory tree belonging to a single subsystem. type PathRule struct { IncludeRegexp string |
