trust-path 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {trust_path-0.3.0 → trust_path-0.4.0}/PKG-INFO +1 -1
- trust_path-0.4.0/benchmark/agents-only.json +5 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/benchmark/corpus.json +3 -0
- trust_path-0.4.0/benchmark/expected.json +31 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/claude-gated.yml +15 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/claude-open.yml +17 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/claude-restricted.yml +20 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/codex-gated.yml +16 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/codex-read-only.yml +17 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/gemini-author-check.yml +16 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/gemini.yml +15 -0
- trust_path-0.4.0/benchmark/fixtures/agents/.github/workflows/no-credential.yml +13 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/benchmark/run.py +24 -7
- {trust_path-0.3.0 → trust_path-0.4.0}/pyproject.toml +1 -1
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/test_analyze.py +40 -3
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/test_benchmark.py +38 -3
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path/__init__.py +1 -1
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path/analyze.py +23 -5
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path.egg-info/PKG-INFO +1 -1
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path.egg-info/SOURCES.txt +9 -0
- trust_path-0.3.0/benchmark/expected.json +0 -17
- {trust_path-0.3.0 → trust_path-0.4.0}/.github/workflows/release.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/.github/workflows/test.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/LICENSE +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/MANIFEST.in +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/README.md +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/setup.cfg +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/__init__.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/agent/.github/workflows/triage.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/head_checkout/.github/workflows/build.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/missing_call/.github/workflows/call.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/pr_title/.github/workflows/greet.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/reusable/.github/workflows/on-comment.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/reusable/.github/workflows/reply.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/safe/.github/workflows/echo-title.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/safe/.github/workflows/label.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/safe/.github/workflows/release.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/safe/.github/workflows/test.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/tags/.github/workflows/a.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/workflow_run_chain/.github/workflows/ci.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/workflow_run_chain/.github/workflows/publish.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/workflow_run_chain/.github/workflows/stage.yml +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/test_cli.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/tests/test_yamlsubset.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path/__main__.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path/cli.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path/yamlsubset.py +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path.egg-info/dependency_links.txt +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path.egg-info/entry_points.txt +0 -0
- {trust_path-0.3.0 → trust_path-0.4.0}/trust_path.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trust-path
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: List the paths by which untrusted input can reach secrets and publishing credentials in GitHub Actions workflows.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/jacob-adm/trust-path
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"agents": {
|
|
3
|
+
"agent_files_by_gate": {
|
|
4
|
+
"anyone": 3,
|
|
5
|
+
"none": 2,
|
|
6
|
+
"write-access": 2
|
|
7
|
+
},
|
|
8
|
+
"by_category": {
|
|
9
|
+
"agent": 23
|
|
10
|
+
},
|
|
11
|
+
"records": 23,
|
|
12
|
+
"refused": 0
|
|
13
|
+
},
|
|
14
|
+
"github-actions-goat": {
|
|
15
|
+
"agent_files_by_gate": {},
|
|
16
|
+
"by_category": {
|
|
17
|
+
"head-code": 2
|
|
18
|
+
},
|
|
19
|
+
"records": 2,
|
|
20
|
+
"refused": 0
|
|
21
|
+
},
|
|
22
|
+
"gravy-overflow": {
|
|
23
|
+
"agent_files_by_gate": {},
|
|
24
|
+
"by_category": {
|
|
25
|
+
"expression": 52,
|
|
26
|
+
"head-code": 19
|
|
27
|
+
},
|
|
28
|
+
"records": 71,
|
|
29
|
+
"refused": 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# The action's default: only users with write access start the agent.
|
|
2
|
+
name: claude-gated
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
pull-requests: write
|
|
9
|
+
jobs:
|
|
10
|
+
assist:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: anthropics/claude-code-action@v1
|
|
14
|
+
with:
|
|
15
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Any user can start the agent; its tools are not limited.
|
|
2
|
+
name: claude-open
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types: [opened]
|
|
6
|
+
permissions:
|
|
7
|
+
issues: write
|
|
8
|
+
jobs:
|
|
9
|
+
triage:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: anthropics/claude-code-action@v1
|
|
13
|
+
with:
|
|
14
|
+
prompt: Label issue ${{ github.event.issue.number }}.
|
|
15
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
16
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
17
|
+
allowed_non_write_users: "*"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Any user can start the agent; the workflow limits its tools.
|
|
2
|
+
name: claude-restricted
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types: [opened]
|
|
6
|
+
permissions:
|
|
7
|
+
issues: write
|
|
8
|
+
jobs:
|
|
9
|
+
triage:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: anthropics/claude-code-action@v1
|
|
13
|
+
with:
|
|
14
|
+
prompt: Label issue ${{ github.event.issue.number }}.
|
|
15
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
16
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
17
|
+
allowed_non_write_users: "*"
|
|
18
|
+
claude_args: |
|
|
19
|
+
--permission-mode auto
|
|
20
|
+
--disallowedTools "WebFetch,WebSearch,Write,Edit"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The action's default gate, and a sandbox that can write the workspace.
|
|
2
|
+
name: codex-gated
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
jobs:
|
|
9
|
+
assist:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: openai/codex-action@v1
|
|
13
|
+
with:
|
|
14
|
+
prompt: Help with issue ${{ github.event.issue.number }}.
|
|
15
|
+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
|
|
16
|
+
sandbox: workspace-write
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Any user can start the agent; it runs in a read-only sandbox.
|
|
2
|
+
name: codex-read-only
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types: [opened]
|
|
6
|
+
permissions:
|
|
7
|
+
issues: read
|
|
8
|
+
jobs:
|
|
9
|
+
classify:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: openai/codex-action@v1
|
|
13
|
+
with:
|
|
14
|
+
prompt: Classify issue ${{ github.event.issue.number }}.
|
|
15
|
+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
|
|
16
|
+
allow-users: "*"
|
|
17
|
+
sandbox: read-only
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The action has no gate of its own; the job's condition tests the author.
|
|
2
|
+
name: gemini-author-check
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
permissions:
|
|
7
|
+
id-token: write
|
|
8
|
+
issues: write
|
|
9
|
+
jobs:
|
|
10
|
+
assist:
|
|
11
|
+
if: contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: google-github-actions/run-gemini-cli@v0
|
|
15
|
+
with:
|
|
16
|
+
prompt: Help with issue ${{ github.event.issue.number }}.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# The action has no gate of its own and the workflow adds none.
|
|
2
|
+
name: gemini
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
permissions:
|
|
7
|
+
id-token: write
|
|
8
|
+
issues: write
|
|
9
|
+
jobs:
|
|
10
|
+
assist:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: google-github-actions/run-gemini-cli@v0
|
|
14
|
+
with:
|
|
15
|
+
prompt: Help with issue ${{ github.event.issue.number }}.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# An agent that holds nothing: no secret, no token scope. Nothing to report.
|
|
2
|
+
name: no-credential
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types: [opened]
|
|
6
|
+
permissions: {}
|
|
7
|
+
jobs:
|
|
8
|
+
summarise:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/ai-inference@v1
|
|
12
|
+
with:
|
|
13
|
+
prompt: Summarise issue ${{ github.event.issue.number }}.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
"""Run trust-path, and zizmor when it is installed, on pinned commits of
|
|
3
|
-
public repositories and
|
|
3
|
+
public repositories and on the agent workflows kept beside this script, and
|
|
4
|
+
compare what they report per workflow file.
|
|
4
5
|
|
|
5
6
|
python3 benchmark/run.py [--corpus FILE] [--expected FILE] [--cache DIR] [--update]
|
|
6
7
|
|
|
@@ -38,7 +39,18 @@ def category(source):
|
|
|
38
39
|
def summarise(records, refused):
|
|
39
40
|
"""The counts kept in the expected file for one repository."""
|
|
40
41
|
by = collections.Counter(category(r["source"]) for r in records)
|
|
41
|
-
return {"records": len(records), "refused": refused, "by_category": dict(sorted(by.items()))
|
|
42
|
+
return {"records": len(records), "refused": refused, "by_category": dict(sorted(by.items())),
|
|
43
|
+
"agent_files_by_gate": agent_gates(records)}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def agent_gates(records):
|
|
47
|
+
"""Number of workflow files with an agent path, for each gate value."""
|
|
48
|
+
gates = collections.defaultdict(set)
|
|
49
|
+
for r in records:
|
|
50
|
+
if category(r["source"]) == "agent":
|
|
51
|
+
gate = r.get("detail", "").split(";")[0].replace("gate=", "") or "unknown"
|
|
52
|
+
gates[gate].add(os.path.basename(r["workflow"]))
|
|
53
|
+
return dict((g, len(files)) for g, files in sorted(gates.items()))
|
|
42
54
|
|
|
43
55
|
|
|
44
56
|
def injection_files(records):
|
|
@@ -103,19 +115,24 @@ def main(argv=None):
|
|
|
103
115
|
else:
|
|
104
116
|
print("zizmor: not installed, comparison skipped")
|
|
105
117
|
for repo in corpus:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
if "path" in repo: # workflows kept beside the corpus file
|
|
119
|
+
name, at = os.path.basename(repo["path"]), "local"
|
|
120
|
+
dest = os.path.join(os.path.dirname(os.path.abspath(args.corpus)), repo["path"])
|
|
121
|
+
else:
|
|
122
|
+
name, at = repo["url"].rstrip("/").split("/")[-1], repo["commit"][:12]
|
|
123
|
+
dest = os.path.join(cache, name + "-" + at)
|
|
124
|
+
fetch(repo["url"], repo["commit"], dest)
|
|
109
125
|
p = _run([sys.executable, "-m", "trust_path", "--json", dest],
|
|
110
126
|
cwd=os.path.dirname(HERE), ok=(0, 1, 2))
|
|
111
127
|
records = json.loads(p.stdout)
|
|
112
128
|
refused = len(p.stderr.splitlines())
|
|
113
129
|
actual[name] = summarise(records, refused)
|
|
114
130
|
files = os.listdir(os.path.join(dest, ".github", "workflows"))
|
|
115
|
-
print("\n%s @ %s (%d workflow files)" % (name,
|
|
131
|
+
print("\n%s @ %s (%d workflow files)" % (name, at, len(files)))
|
|
116
132
|
print(" trust-path: %(records)d records, %(refused)d files refused, "
|
|
117
133
|
"%(by_category)s" % actual[name])
|
|
118
|
-
print(" trust-path: %d files with an agent path" %
|
|
134
|
+
print(" trust-path: %d files with an agent path, by gate %s" % (
|
|
135
|
+
len(agent_files(records)), actual[name]["agent_files_by_gate"]))
|
|
119
136
|
if have_zizmor:
|
|
120
137
|
findings = json.loads(_run(ZIZMOR + [dest], ok=tuple(range(15))).stdout or "[]")
|
|
121
138
|
print(" injection, by workflow file: %s" % compare(
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "trust-path"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.4.0"
|
|
9
9
|
description = "List the paths by which untrusted input can reach secrets and publishing credentials in GitHub Actions workflows."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.9"
|
|
@@ -66,10 +66,47 @@ class AgentDetailTests(unittest.TestCase):
|
|
|
66
66
|
self.assertEqual(agent("openai/codex-action@v1", "allow-users: ${{ vars.USERS }}"),
|
|
67
67
|
["gate=expression; sandbox=action-default; safety-strategy=drop-sudo"])
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
self.assertEqual(agent("google-github-actions/run-gemini-cli@v0"), ["gate=
|
|
69
|
+
def test_gate_of_other_actions(self):
|
|
70
|
+
self.assertEqual(agent("google-github-actions/run-gemini-cli@v0"), ["gate=none"])
|
|
71
|
+
self.assertEqual(agent("actions/ai-inference@v1"), ["gate=none"])
|
|
71
72
|
self.assertEqual(agent("anthropics/claude-code-base-action@v1"),
|
|
72
|
-
["gate=
|
|
73
|
+
["gate=none; tools=action-default"])
|
|
74
|
+
self.assertEqual(agent("warpdotdev/oz-agent-action@v1"), ["gate=not-modelled"])
|
|
75
|
+
|
|
76
|
+
CONDITION = """
|
|
77
|
+
on: issue_comment
|
|
78
|
+
permissions:
|
|
79
|
+
id-token: write
|
|
80
|
+
jobs:
|
|
81
|
+
j:
|
|
82
|
+
runs-on: ubuntu-latest%s
|
|
83
|
+
steps:
|
|
84
|
+
- uses: google-github-actions/run-gemini-cli@v0%s
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def conditions(self, job="", step=""):
|
|
88
|
+
job = job and "\n if: " + job
|
|
89
|
+
step = step and "\n if: " + step
|
|
90
|
+
return details(analyse(w=self.CONDITION % (job, step), detail=True))
|
|
91
|
+
|
|
92
|
+
def test_if_conditions_that_test_who_started_the_run(self):
|
|
93
|
+
self.assertEqual(self.conditions(), ["gate=none"])
|
|
94
|
+
self.assertEqual(self.conditions(
|
|
95
|
+
job="contains(fromJSON('[\"OWNER\",\"MEMBER\"]'), "
|
|
96
|
+
"github.event.comment.author_association)"),
|
|
97
|
+
["gate=none; if=author_association"])
|
|
98
|
+
self.assertEqual(self.conditions(step="${{ github.actor == 'octocat' }}"),
|
|
99
|
+
["gate=none; if=actor"])
|
|
100
|
+
self.assertEqual(self.conditions(
|
|
101
|
+
job="github.event.sender.login == 'octocat'",
|
|
102
|
+
step="github.event.comment.author_association == 'OWNER'"),
|
|
103
|
+
["gate=none; if=actor+author_association"])
|
|
104
|
+
|
|
105
|
+
def test_other_if_conditions_are_not_reported(self):
|
|
106
|
+
self.assertEqual(self.conditions(job="github.event_name == 'issue_comment'"),
|
|
107
|
+
["gate=none"])
|
|
108
|
+
self.assertEqual(self.conditions(step="contains(github.event.comment.body, '@bot')"),
|
|
109
|
+
["gate=none"])
|
|
73
110
|
|
|
74
111
|
def test_claude_tool_flags(self):
|
|
75
112
|
self.assertEqual(agent(
|
|
@@ -42,7 +42,20 @@ class PureTests(unittest.TestCase):
|
|
|
42
42
|
def test_summarise(self):
|
|
43
43
|
records = [rec("issues:github.event.issue.title"), rec("issues:event text read by agent")]
|
|
44
44
|
self.assertEqual(bench.summarise(records, 1), {
|
|
45
|
-
"records": 2, "refused": 1, "by_category": {"agent": 1, "expression": 1}
|
|
45
|
+
"records": 2, "refused": 1, "by_category": {"agent": 1, "expression": 1},
|
|
46
|
+
"agent_files_by_gate": {"unknown": 1}})
|
|
47
|
+
|
|
48
|
+
def test_agent_gates_count_files(self):
|
|
49
|
+
def agent(workflow, detail):
|
|
50
|
+
return {"source": "issues:event text read by agent", "workflow": workflow,
|
|
51
|
+
"detail": detail}
|
|
52
|
+
records = [agent("a.yml", "gate=anyone; tools=action-default"),
|
|
53
|
+
agent("a.yml", "gate=anyone; tools=action-default"),
|
|
54
|
+
agent("b.yml", "gate=anyone; sandbox=read-only"),
|
|
55
|
+
agent("c.yml", "gate=write-access"),
|
|
56
|
+
{"source": "issues:github.event.issue.title", "workflow": "d.yml",
|
|
57
|
+
"detail": "-"}]
|
|
58
|
+
self.assertEqual(bench.agent_gates(records), {"anyone": 2, "write-access": 1})
|
|
46
59
|
|
|
47
60
|
def test_files_and_compare(self):
|
|
48
61
|
records = [rec("issues:github.event.issue.title", ".github/workflows/a.yml"),
|
|
@@ -60,6 +73,26 @@ class PureTests(unittest.TestCase):
|
|
|
60
73
|
{"both": 1, "trust-path only": 1, "zizmor only": 1})
|
|
61
74
|
|
|
62
75
|
|
|
76
|
+
class LocalCorpusTests(unittest.TestCase):
|
|
77
|
+
def test_shipped_agent_workflows_match_the_expected_file(self):
|
|
78
|
+
"""The agent workflows beside the script need no network."""
|
|
79
|
+
tmp = tempfile.mkdtemp()
|
|
80
|
+
self.addCleanup(shutil.rmtree, tmp)
|
|
81
|
+
here = os.path.join(ROOT, "benchmark")
|
|
82
|
+
corpus = os.path.join(here, "agents-only.json")
|
|
83
|
+
with open(os.path.join(here, "expected.json")) as f:
|
|
84
|
+
expected = {"agents": json.load(f)["agents"]}
|
|
85
|
+
with open(os.path.join(tmp, "expected.json"), "w") as f:
|
|
86
|
+
json.dump(expected, f)
|
|
87
|
+
out = io.StringIO()
|
|
88
|
+
with contextlib.redirect_stdout(out):
|
|
89
|
+
code = bench.main(["--corpus", corpus, "--expected",
|
|
90
|
+
os.path.join(tmp, "expected.json")])
|
|
91
|
+
self.assertEqual(code, 0, out.getvalue())
|
|
92
|
+
self.assertEqual(expected["agents"]["agent_files_by_gate"],
|
|
93
|
+
{"anyone": 3, "none": 2, "write-access": 2})
|
|
94
|
+
|
|
95
|
+
|
|
63
96
|
class RunTests(unittest.TestCase):
|
|
64
97
|
"""main() on a workflow already in the cache, so nothing is fetched."""
|
|
65
98
|
|
|
@@ -87,12 +120,14 @@ class RunTests(unittest.TestCase):
|
|
|
87
120
|
self.assertEqual(self.run_main("--update")[0], 0)
|
|
88
121
|
with open(self.expected) as f:
|
|
89
122
|
self.assertEqual(json.load(f), {"repo": {
|
|
90
|
-
"records": 2, "refused": 0, "by_category": {"expression": 2}
|
|
123
|
+
"records": 2, "refused": 0, "by_category": {"expression": 2},
|
|
124
|
+
"agent_files_by_gate": {}}})
|
|
91
125
|
code, out = self.run_main()
|
|
92
126
|
self.assertEqual(code, 0)
|
|
93
127
|
self.assertIn("trust-path counts match", out)
|
|
94
128
|
with open(self.expected, "w") as f:
|
|
95
|
-
json.dump({"repo": {"records": 3, "refused": 0, "by_category": {"expression": 3}
|
|
129
|
+
json.dump({"repo": {"records": 3, "refused": 0, "by_category": {"expression": 3},
|
|
130
|
+
"agent_files_by_gate": {}}}, f)
|
|
96
131
|
code, out = self.run_main()
|
|
97
132
|
self.assertEqual(code, 1)
|
|
98
133
|
self.assertIn("DIFFERENT", out)
|
|
@@ -85,6 +85,18 @@ AGENT_GATES = {
|
|
|
85
85
|
"anthropics/claude-code-action": "allowed_non_write_users",
|
|
86
86
|
"openai/codex-action": "allow-users",
|
|
87
87
|
}
|
|
88
|
+
# Agent actions with no input or check of their own for who starts them:
|
|
89
|
+
# whoever can trigger the workflow starts the agent.
|
|
90
|
+
AGENT_UNGATED = (
|
|
91
|
+
"actions/ai-inference",
|
|
92
|
+
"anthropics/claude-code-base-action",
|
|
93
|
+
"google-github-actions/run-gemini-cli",
|
|
94
|
+
)
|
|
95
|
+
# What an `if:` condition tests when it restricts who started the run.
|
|
96
|
+
_IF_TESTS = (
|
|
97
|
+
("actor", re.compile(r"github\.(triggering_)?actor\b|\b(sender|user)\.login\b")),
|
|
98
|
+
("author_association", re.compile(r"\bauthor_association\b")),
|
|
99
|
+
)
|
|
88
100
|
_CLAUDE_FLAGS = re.compile(
|
|
89
101
|
r"--(allowed-?tools|disallowed-?tools|permission-mode|dangerously-skip-permissions)"
|
|
90
102
|
r"(?:(?:\s+|=)(\"[^\"]*\"|'[^']*'|[^\s-]\S*))?", re.I)
|
|
@@ -177,9 +189,11 @@ def _action(uses):
|
|
|
177
189
|
return "/".join(uses.split("@")[0].split("/")[:2]).lower()
|
|
178
190
|
|
|
179
191
|
|
|
180
|
-
def agent_detail(action, with_):
|
|
181
|
-
"""What the workflow sets on an agent action: who may start it (gate)
|
|
182
|
-
|
|
192
|
+
def agent_detail(action, with_, conditions=()):
|
|
193
|
+
"""What the workflow sets on an agent action: who may start it (gate),
|
|
194
|
+
what the job's and step's `if:` conditions test about the person who
|
|
195
|
+
started the run, and what the agent may do. Values are the workflow's
|
|
196
|
+
own, not a judgement; conditions are not evaluated."""
|
|
183
197
|
def text(key):
|
|
184
198
|
return with_[key].strip() if isinstance(with_.get(key), str) else ""
|
|
185
199
|
|
|
@@ -189,7 +203,11 @@ def agent_detail(action, with_):
|
|
|
189
203
|
parts.append("gate=" + ("write-access" if not gate else "anyone" if gate == "*"
|
|
190
204
|
else "expression" if "${{" in gate else "listed-users"))
|
|
191
205
|
else:
|
|
192
|
-
parts.append("gate=not-modelled")
|
|
206
|
+
parts.append("gate=none" if action in AGENT_UNGATED else "gate=not-modelled")
|
|
207
|
+
text_if = " ".join(c for c in conditions if isinstance(c, str))
|
|
208
|
+
tests = [name for name, pattern in _IF_TESTS if pattern.search(text_if)]
|
|
209
|
+
if tests:
|
|
210
|
+
parts.append("if=" + "+".join(tests))
|
|
193
211
|
if action.startswith("anthropics/"):
|
|
194
212
|
flags = []
|
|
195
213
|
for m in _CLAUDE_FLAGS.finditer(text("claude_args")):
|
|
@@ -469,7 +487,7 @@ class Repo(object):
|
|
|
469
487
|
entries.add((i, "artifact from upstream run"))
|
|
470
488
|
if action in AGENT_ACTIONS:
|
|
471
489
|
entries.add((i, "event text read by agent"))
|
|
472
|
-
details[i] = agent_detail(action, with_)
|
|
490
|
+
details[i] = agent_detail(action, with_, (job.get("if"), step.get("if")))
|
|
473
491
|
|
|
474
492
|
for start, what in sorted(entries):
|
|
475
493
|
source = "%s:%s" % (ctx.chain, what)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trust-path
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: List the paths by which untrusted input can reach secrets and publishing credentials in GitHub Actions workflows.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/jacob-adm/trust-path
|
|
@@ -4,9 +4,18 @@ README.md
|
|
|
4
4
|
pyproject.toml
|
|
5
5
|
.github/workflows/release.yml
|
|
6
6
|
.github/workflows/test.yml
|
|
7
|
+
benchmark/agents-only.json
|
|
7
8
|
benchmark/corpus.json
|
|
8
9
|
benchmark/expected.json
|
|
9
10
|
benchmark/run.py
|
|
11
|
+
benchmark/fixtures/agents/.github/workflows/claude-gated.yml
|
|
12
|
+
benchmark/fixtures/agents/.github/workflows/claude-open.yml
|
|
13
|
+
benchmark/fixtures/agents/.github/workflows/claude-restricted.yml
|
|
14
|
+
benchmark/fixtures/agents/.github/workflows/codex-gated.yml
|
|
15
|
+
benchmark/fixtures/agents/.github/workflows/codex-read-only.yml
|
|
16
|
+
benchmark/fixtures/agents/.github/workflows/gemini-author-check.yml
|
|
17
|
+
benchmark/fixtures/agents/.github/workflows/gemini.yml
|
|
18
|
+
benchmark/fixtures/agents/.github/workflows/no-credential.yml
|
|
10
19
|
tests/__init__.py
|
|
11
20
|
tests/test_analyze.py
|
|
12
21
|
tests/test_benchmark.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/head_checkout/.github/workflows/build.yml
RENAMED
|
File without changes
|
{trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/missing_call/.github/workflows/call.yml
RENAMED
|
File without changes
|
|
File without changes
|
{trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/reusable/.github/workflows/on-comment.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/workflow_run_chain/.github/workflows/ci.yml
RENAMED
|
File without changes
|
|
File without changes
|
{trust_path-0.3.0 → trust_path-0.4.0}/tests/fixtures/workflow_run_chain/.github/workflows/stage.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|