Skip to content

Commit 274b007

Browse files
hotlongclaude
andcommitted
chore: temporary token probe, deleted with its branch
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d848df commit 274b007

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Temporary one-off probe for #29160. Prints HTTP statuses only, never an advisory's id or text. Deleted with its branch.
2+
name: tmp advisory token probe
3+
on:
4+
push:
5+
branches: ['claude/advisory-token-probe']
6+
permissions: {}
7+
jobs:
8+
probe:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 5
11+
steps:
12+
- id: narrow
13+
continue-on-error: true
14+
uses: actions/create-github-app-token@v3
15+
with:
16+
app-id: ${{ vars.OS_FLEET_APP_ID }}
17+
private-key: ${{ secrets.OS_FLEET_PRIVATE_KEY }}
18+
owner: objectstack-ai
19+
repositories: objectstack
20+
permission-repository-advisories: write
21+
permission-metadata: read
22+
- id: control
23+
continue-on-error: true
24+
uses: actions/create-github-app-token@v3
25+
with:
26+
app-id: ${{ vars.OS_FLEET_APP_ID }}
27+
private-key: ${{ secrets.OS_FLEET_PRIVATE_KEY }}
28+
owner: objectstack-ai
29+
repositories: objectstack
30+
permission-metadata: read
31+
- name: Probe (statuses only)
32+
env:
33+
NARROW: ${{ steps.narrow.outputs.token }}
34+
CONTROL: ${{ steps.control.outputs.token }}
35+
NARROW_OUTCOME: ${{ steps.narrow.outcome }}
36+
CONTROL_OUTCOME: ${{ steps.control.outcome }}
37+
run: |
38+
cat > probe.mjs <<'EOF'
39+
const R = 'repos/objectstack-ai/objectstack', API = 'https://api.github.com/';
40+
const call = async (verb, path, t, body) => {
41+
const r = await fetch(API + path, { method: verb, headers: { accept: 'application/vnd.github+json', authorization: 'Bearer ' + t, 'x-github-api-version': '2022-11-28', 'content-type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body) });
42+
let j = null; try { j = await r.json(); } catch {}
43+
return { s: r.status, j, h: r.headers.get('x-accepted-github-permissions') ?? '-' };
44+
};
45+
const generic = (x) => (x.s >= 400 ? String(x.j?.message ?? '').replace(/GHSA-[a-z0-9-]+/gi, 'GHSA').slice(0, 90) : '');
46+
const probe = async (label, t) => {
47+
const say = (what, x, extra = '') => console.log(`[${label}] ${what}: HTTP ${x.s} ${generic(x)} ${extra} accepted=${x.h}`);
48+
if (!t) { console.log(`[${label}] no token`); return; }
49+
const list = await call('GET', `${R}/security-advisories?state=draft&per_page=100`, t);
50+
const rows = Array.isArray(list.j) ? list.j : [];
51+
say('GET list draft', list, `count=${rows.length}`);
52+
say('POST reports, empty body on purpose', await call('POST', `${R}/security-advisories/reports`, t, {}));
53+
say('POST create, empty body on purpose', await call('POST', `${R}/security-advisories`, t, {}));
54+
const target = process.env.TARGET_ID ?? rows[0]?.ghsa_id;
55+
if (label === 'narrow' && target) process.env.TARGET_ID = target;
56+
if (!target) { console.log(`[${label}] no draft readable, PATCH not sent`); return; }
57+
const one = await call('GET', `${R}/security-advisories/${target}`, t);
58+
const cu = Array.isArray(one.j?.collaborating_users) ? one.j.collaborating_users.map((u) => u.login) : null;
59+
say('GET one draft', one, `state=${one.j?.state ?? '-'} collaborators=${cu ? cu.length : '-'}`);
60+
say('PATCH empty body', await call('PATCH', `${R}/security-advisories/${target}`, t, {}));
61+
if (cu) {
62+
say('PATCH same collaborators', await call('PATCH', `${R}/security-advisories/${target}`, t, { collaborating_users: cu }));
63+
const after = await call('GET', `${R}/security-advisories/${target}`, t);
64+
console.log(`[${label}] collaborators unchanged=${JSON.stringify(cu) === JSON.stringify((after.j?.collaborating_users ?? []).map((u) => u.login))}`);
65+
} else console.log(`[${label}] PATCH same collaborators not sent: draft unread`);
66+
};
67+
console.log('mint outcome narrow=' + process.env.NARROW_OUTCOME + ' control=' + process.env.CONTROL_OUTCOME);
68+
await probe('narrow', process.env.NARROW);
69+
await probe('control', process.env.CONTROL);
70+
EOF
71+
node probe.mjs

0 commit comments

Comments
 (0)