-
Notifications
You must be signed in to change notification settings - Fork 0
cybersecurity-attack-paths: fix p.relationships label handling (1.17+ format), pin 1.21.1 #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| Enumerates multi-step attack chains across an enterprise asset graph by composing | ||
| distinct attacker techniques in series -- a capability unlocked by multi-edge path | ||
| patterns (relationalai>=1.15): | ||
| patterns (relationalai>=1.21): | ||
|
|
||
| - Loads Asset nodes (hosts, services, accounts) and three DISTINCT directed edges | ||
| between them, one per technique: exploit_to (vulnerability exploitation), | ||
|
|
@@ -109,7 +109,7 @@ def load_csv(filename): | |
|
|
||
| # -------------------------------------------------- | ||
| # Paths: kill-chain attack paths (multi-relationship sequence) | ||
| # PREVIEW capability; requires relationalai>=1.15. | ||
| # PREVIEW capability; requires relationalai>=1.21. | ||
| # -------------------------------------------------- | ||
| # model.path(a.exploit_to, b.cred_to, c.pivot_to.repeat(1, MAX_PIVOTS), dst) is a | ||
| # MULTI-EDGE pattern: distinct relationships in series. It matches the kill-chain | ||
|
|
@@ -157,16 +157,12 @@ def load_csv(filename): | |
| hop_df = hop_df.drop_duplicates(["path_id", "hop"]).sort_values(["path_id", "hop"]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to drop duplicates? There shouldn't be any, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a question for @cafzal |
||
|
|
||
| # Reassemble each kill-chain: ordered asset names + the technique used at each hop. | ||
| def technique_label(raw): | ||
| # relationship labels arrive as e.g. "-<exploit_to>->"; strip to the verb stem. | ||
| stem = raw.strip("-<>⟨⟩→ ") | ||
| return stem[:-3] if stem.endswith("_to") else stem | ||
|
|
||
| # The technique is the relationship label as-is -- the dotted relationship name, | ||
| # e.g. "Asset.exploit_to". | ||
| chains = [] | ||
| for pid, g in kill_df.groupby("path_id"): | ||
| assets = list(g.sort_values("step")["asset_name"]) | ||
| techs = [technique_label(t) for t in | ||
| hop_df[hop_df["path_id"] == pid].sort_values("hop")["technique"]] | ||
| techs = list(hop_df[hop_df["path_id"] == pid].sort_values("hop")["technique"]) | ||
| labelled = assets[0] | ||
| for nm, tech in zip(assets[1:], techs): | ||
| labelled += f" --[{tech}]--> {nm}" | ||
|
|
@@ -183,7 +179,7 @@ def technique_label(raw): | |
| # -------------------------------------------------- | ||
| # Pin both endpoints by id and enumerate all simple routes between them over the | ||
| # technique-agnostic can_reach edge (any technique, 1..MAX_ROUTE_HOPS). This is the | ||
| # >=1.15 native point query -- src/dst unified to specific assets inside all_paths(). | ||
| # >=1.15-era native point query (still current) -- src/dst unified to specific assets inside all_paths(). | ||
|
|
||
| src_pt, dst_pt = Asset.ref(), Asset.ref() | ||
| route = model.path(src_pt.can_reach.repeat(1, MAX_ROUTE_HOPS), dst_pt).all_paths() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the part of the PR comment:
Seems like we should update their pins too, right? Otherwise the AIs learning from these examples will think they need to run on older versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for @cafzal: Is it better to leave these minimum bounds more permissive, or to keep things updated to encourage the AIs that are reading these files to use the latest version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just focus on supporting 1.21+. we'll make that clear in skills repo readme and setup skill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this out of this PR - there are dozens of templates that may need updating.