Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7073906
feat(commitperclip): add get-bot-token.mjs — generate installation token
brandonburr May 20, 2026
4accce2
feat(commitperclip): add PR template compliance gate
brandonburr May 20, 2026
7594fa1
feat(commitperclip): add linked issue gate
brandonburr May 20, 2026
09a75ec
feat(commitperclip): add test coverage gate
brandonburr May 20, 2026
34250da
feat(commitperclip): add lockfile guard gate
brandonburr May 20, 2026
96835c3
fix: exempt .github/scripts/check-*.mjs from gitignore
brandonburr May 20, 2026
3cae559
fix(commitperclip): tighten #NNN pattern — require non-word boundary …
brandonburr May 20, 2026
7ba72c5
feat(commitperclip): add new dependency notice gate
brandonburr May 20, 2026
77db6c7
feat(commitperclip): add quality gate orchestrator with comment upsert
brandonburr May 20, 2026
6ea25e7
fix(commitperclip): deduplicate findExistingComment API call in orche…
brandonburr May 20, 2026
77b5a14
feat(commitperclip): add security gate with 6 checks and draft adviso…
brandonburr May 20, 2026
c488368
feat(commitperclip): add PR review workflow, CodeQL analysis, and Dep…
brandonburr May 20, 2026
5900144
feat(commitperclip): add security-review check run — pending blocks m…
brandonburr May 20, 2026
547aa3f
feat(commitperclip): add Dependency Review gate — fails on CVE-vulner…
brandonburr May 20, 2026
8d9d967
fix: remove duplicate codeql.yml — CodeQL already runs via repo defau…
brandonburr May 20, 2026
7b80285
fix: sanitize PR_NUMBER and GH_REPO before URL construction (SSRF)
brandonburr May 20, 2026
4e33ee0
feat(commitperclip): make gates conventional-commit-aware — skip docs…
brandonburr May 20, 2026
2a7d74a
fix: re-derive sensitive paths against current master + reframe lockf…
brandonburr May 30, 2026
16e65f7
feat(commitperclip): self-validate SENSITIVE_PATHS — fail workflow lo…
brandonburr May 30, 2026
10f04b4
fix(commitperclip): paginate PR file fetches
devinfoley May 30, 2026
128d8fd
fix(commitperclip): scope token installs and base refs
devinfoley May 30, 2026
8745685
fix(commitperclip): tighten linked issue URL matching
devinfoley May 30, 2026
321581b
fix(commitperclip): address remaining Greptile security feedback
devinfoley May 30, 2026
a2cff69
fix(commitperclip): close remaining Greptile gaps
devinfoley May 30, 2026
d914753
fix(commitperclip): harden security gate parsing
devinfoley May 30, 2026
87f155c
fix(commitperclip): count bullets and paragraphs as sentences
devinfoley Jun 1, 2026
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
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
day: monday
time: "06:00"
open-pull-requests-limit: 10
labels:
- "dependencies"
ignore:
# Ignore major version bumps — review those manually
- dependency-name: "*"
update-types: ["version-update:semver-major"]

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: monday
time: "06:00"
open-pull-requests-limit: 5
89 changes: 89 additions & 0 deletions .github/scripts/check-pr-dependencies.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env node
/**
* check-pr-dependencies.mjs
* Detects new npm packages added in this PR vs. the base branch.
* Never fails (informational only) — outputs { passed: true, informational: string[] }
*/
import { fileURLToPath } from 'node:url';
import { ghFetch } from './get-bot-token.mjs';

function buildContentsPath(repo, filename, ref) {
return `/repos/${repo}/contents/${filename}?${new URLSearchParams({ ref }).toString()}`;
}

export async function resolveBaseRef(fetchFromGitHub, token, repo, prNumber, baseRef) {
if (baseRef) {
return baseRef;
}

const pr = await fetchFromGitHub(`/repos/${repo}/pulls/${prNumber}`, token);
if (pr.base?.ref) {
return pr.base.ref;
}

const repository = await fetchFromGitHub(`/repos/${repo}`, token);
if (repository.default_branch) {
return repository.default_branch;
}

throw new Error(`Unable to resolve a base branch for ${repo}#${prNumber}.`);
}

export async function checkDependencies(files, token, repo, prNumber, baseRef, fetchFromGitHub = ghFetch) {
const pkgFiles = files.filter(
f => f.filename.endsWith('package.json') &&
!f.filename.includes('node_modules') &&
f.status !== 'removed'
);

if (pkgFiles.length === 0) return { passed: true, informational: [] };

const resolvedBaseRef = await resolveBaseRef(fetchFromGitHub, token, repo, prNumber, baseRef);
const newPackages = new Set();

for (const file of pkgFiles) {
try {
const [baseRes, prRes] = await Promise.all([
fetchFromGitHub(buildContentsPath(repo, file.filename, resolvedBaseRef), token),
fetchFromGitHub(buildContentsPath(repo, file.filename, `refs/pull/${prNumber}/head`), token),
]);

const basePkg = JSON.parse(Buffer.from(baseRes.content, 'base64').toString());
const prPkg = JSON.parse(Buffer.from(prRes.content, 'base64').toString());

const baseDeps = new Set([
...Object.keys(basePkg.dependencies ?? {}),
...Object.keys(basePkg.devDependencies ?? {}),
...Object.keys(basePkg.peerDependencies ?? {}),
]);

for (const dep of [
...Object.keys(prPkg.dependencies ?? {}),
...Object.keys(prPkg.devDependencies ?? {}),
...Object.keys(prPkg.peerDependencies ?? {}),
]) {
if (!baseDeps.has(dep)) newPackages.add(dep);
}
} catch {
// File may not exist on base — skip
}
}

if (newPackages.size === 0) return { passed: true, informational: [] };

const pkgList = [...newPackages].map(p => `\`${p}\``).join(', ');
return {
passed: true,
informational: [
`📦 New dependencies added: ${pkgList}. Review may take longer and new dependencies ` +
`are less likely to be accepted — please check if existing deps cover this need.`,
],
};
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
const { GH_TOKEN, GH_REPO, PR_NUMBER, PR_FILES, PR_BASE_REF } = process.env;
const files = JSON.parse(PR_FILES ?? '[]');
const result = await checkDependencies(files, GH_TOKEN, GH_REPO, PR_NUMBER, PR_BASE_REF);
console.log(JSON.stringify(result));
}
53 changes: 53 additions & 0 deletions .github/scripts/check-pr-linked-issue.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node
/**
* check-pr-linked-issue.mjs
* Checks that a PR body references a GitHub issue. Respects conventional commit
* prefixes — skips check for docs/chore/build/ci/style/test prefixed PRs.
* Export: checkLinkedIssue(prBody: string, prTitle: string) → { passed, failures }
*/
import { fileURLToPath } from 'node:url';

const ISSUE_PATTERNS = [
/(?:fixes|closes|resolves)\s+#\d+/i,
/(?:^|[\s(])https:\/\/github\.com\/paperclipai\/paperclip\/issues\/\d+(?=$|[\s),:;!?]|[.](?![\w-]))/i,
/(?<!\w)#\d+/,
];

// Prefixes where a linked issue is NOT required
const SKIP_ISSUE_PREFIXES = ['docs', 'chore', 'build', 'ci', 'style', 'test', 'revert'];

function parsePrefix(title) {
if (!title) return null;
const match = title.match(/^([a-z]+)(?:\([^)]*\))?:/);
return match ? match[1].toLowerCase() : null;
}

export function checkLinkedIssue(body, prTitle = '') {
const prefix = parsePrefix(prTitle);

if (prefix && SKIP_ISSUE_PREFIXES.includes(prefix)) {
return { passed: true, failures: [] };
}

if (!body || !body.trim()) {
return { passed: false, failures: ['PR body is empty — please fill out the PR template'] };
}

const found = ISSUE_PATTERNS.some(p => p.test(body));
return {
passed: found,
failures: found ? [] : [
'No linked issue found — please add `Fixes #NNN` to your PR description. ' +
'If no issue exists yet, please file one first: ' +
'https://github.com/paperclipai/paperclip/issues/new',
],
};
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
const body = process.env.PR_BODY ?? '';
const title = process.env.PR_TITLE ?? '';
const result = checkLinkedIssue(body, title);
console.log(JSON.stringify(result));
process.exit(result.passed ? 0 : 1);
}
31 changes: 31 additions & 0 deletions .github/scripts/check-pr-lockfile.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node
/**
* check-pr-lockfile.mjs
* Checks that pnpm-lock.yaml was not manually edited.
* Export: checkLockfile(files, prAuthor, prBranch) → { passed, failures }
*/
import { fileURLToPath } from 'node:url';

export function checkLockfile(files, prAuthor, prBranch) {
const lockfileChanged = files.some(f => f.filename === 'pnpm-lock.yaml');
if (!lockfileChanged) return { passed: true, failures: [] };

const isRefreshBot =
prAuthor === 'github-actions[bot]' && prBranch === 'chore/refresh-lockfile';

return {
passed: isRefreshBot,
failures: isRefreshBot ? [] : [
'You have changes to `pnpm-lock.yaml` — `pr.yml` will hard-fail this PR with a confusing message about lockfile edits. ' +
'To fix: run `pnpm install` locally, exclude the lockfile from your commit, push again. ' +
'The lockfile is regenerated automatically by the refresh bot on a schedule.',
],
};
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
const files = JSON.parse(process.env.PR_FILES ?? '[]');
const result = checkLockfile(files, process.env.PR_AUTHOR ?? '', process.env.PR_BRANCH ?? '');
console.log(JSON.stringify(result));
process.exit(result.passed ? 0 : 1);
}
Loading
Loading