Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 11 additions & 61 deletions .github/workflows/issue-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Runs the repo's /is prompt against an issue when the `diffex-analyze` label is added
# or when a staff member comments `@issuron analyze` anywhere on an issue.
# or when a repository maintainer comments `@issuron analyze` anywhere on an issue.
#
# Comment triggers can include one `#run-on-*` tag anywhere in the text:
# @issuron analyze #run-on-linux -> ubuntu-latest (default)
Expand All @@ -14,9 +14,7 @@
# `DIFFEX_AUTH_JSON` secret containing the contents of a Diffex auth.json
# (~/.diffex/agent/auth.json).
# 2. Create the `diffex-analyze` label.
# 3. Add a repository secret `EARENDIL_ORG_READ_TOKEN` with permission to
# read `earendil-works` org membership. The authorization job uses it to
# verify that the label actor is an active member of `earendil-works/staff`.
# 3. Authorization uses the repository token to require write or admin permission.
# 4. Add an environment secret `DIFFEX_GIST_TOKEN` on `diffex-analyze` with gist
# creation permission. The analysis job uses it to upload the exported
# session gist.
Expand Down Expand Up @@ -74,8 +72,6 @@ jobs:
- name: Verify sender permission
id: verify
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
ORG_READ_TOKEN: ${{ secrets.EARENDIL_ORG_READ_TOKEN }}
with:
script: |
const ANALYZE_LABEL = 'diffex-analyze';
Expand Down Expand Up @@ -171,66 +167,20 @@ jobs:
}
}

if (!process.env.ORG_READ_TOKEN) {
await removeTriggerLabel();
core.setFailed('EARENDIL_ORG_READ_TOKEN is not configured; refusing to run issue analysis.');
return;
}

try {
const response = await fetch(
`https://api.github.com/orgs/earendil-works/teams/staff/memberships/${encodeURIComponent(username)}`,
{
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${process.env.ORG_READ_TOKEN}`,
'X-GitHub-Api-Version': '2022-11-28',
},
},
);

if (response.status === 404) {
await removeTriggerLabel();
core.setFailed(`@${username} is not an active earendil-works/staff member.`);
return;
}

if (!response.ok) {
const body = await response.text();
await removeTriggerLabel();
core.setFailed(
`Could not verify earendil-works/staff membership for @${username}: HTTP ${response.status} ${body}`,
);
return;
}

const membership = await response.json();
if (membership.state !== 'active') {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username,
});
if (!['admin', 'write'].includes(data.permission)) {
await removeTriggerLabel();
core.setFailed(`@${username} is not an active earendil-works/staff member.`);
core.setFailed(`@${username} requires repository write or admin permission to trigger issue analysis.`);
return;
}
console.log(`earendil-works/staff membership for @${username}: ${membership.state}`);
} catch (error) {
} catch {
await removeTriggerLabel();
core.setFailed(
`Could not verify earendil-works/staff membership for @${username}: ${
error instanceof Error ? error.message : String(error)
}`,
);
return;
}

const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username,
});
if (!['admin', 'write'].includes(data.permission)) {
await removeTriggerLabel();
core.setFailed(
`@${username} has '${data.permission}' permission; write or admin is required to trigger issue analysis.`,
);
core.setFailed('Could not verify repository permission; refusing to run issue analysis.');
return;
}

Expand Down
17 changes: 8 additions & 9 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This document should guide you about understanding the security concept behind
Diffex and also where the boundaries are.

In general Diffex is a coding agent that runs locally within the security boundary
of the user that is running it. It's the responsibiltiy of the user to monitor
of the user that is running it. It's the responsibility of the user to monitor
its operations or to contain it within a container, virtual machine or other
Sandbox solution.

Expand All @@ -24,10 +24,9 @@ coding agent trivially and this cannot be protected against.
## Reporting a Vulnerability

If you believe you found a security vulnerability in Diffex or another package in
this repository, please report it privately by either:

- Emailing `security@earendil.com`, or
- Opening a private report through GitHub Security Advisories for this repository
this repository, contact a Diffex repository owner privately through your existing repository access.
A dedicated public security mailbox and GitHub private reporting channel have not yet been verified.
Do not send sensitive reports to an upstream project.

Please include:

Expand All @@ -42,7 +41,7 @@ reports and coordinate disclosure as appropriate.
## Scope

Security issues in the distributed packages, command-line tools, APIs, and
repository code are in scope as well as Diffex-operated infrastricture
repository code are in scope as well as Diffex-operated infrastructure
on `diffex.ai`.

## Out Of Scope
Expand All @@ -51,7 +50,7 @@ on `diffex.ai`.
- Behavior of Diffex extensions or skills installed by the user
- Risks from working in untrusted repositories
- Risks from installing untrusted extensions, skills, packages, or tools
- Isuses caused by non trustworthy MITM proxies
- Issues caused by non trustworthy MITM proxies
- Public internet exposure of a Diffex installation
- Prompt injection attacks
- Exposed secrets that are third-party/user-controlled credentials
Expand Down Expand Up @@ -83,5 +82,5 @@ When possible, include the exact affected path, package version or commit SHA,
configuration, and a proof of concept against the latest release or latest
`main`. For dependency reports, include evidence that the shipped dependency is
affected and that the issue is reachable through Diffex. For exposed-secret reports,
include evidence that the credential is owned by Earendil or grants access to
Earendil-operated infrastructure or services.
include evidence that the credential is owned by Diffex or grants access to
Diffex-operated infrastructure or services.
Loading
Loading