agentleFS
epamepam/ai-dial-chat/.claude/skills/fix-cve-backport/SKILL.md

fix-cve-backport

Skill501 starsChanged 17 days agoApache-2.0View on GitHub

Discover and fix CVEs in AI DIAL Chat dependencies or container images and backport fixes to the two newest release-X.Y branches. Automatically scan when no CVE or report is supplied. Use for vulnerability remediation with release backports, or to backport an existing security fix. Not a general dependency-upgrade workflow.

The file

Show its rules and text

We split this skill into the rules it gives an agent

21 rules. About 0 are common, 17 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈17

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep unrelated edits intact.

    line 29
  2. Very specific:

    Read the repository's AGENTS.md and relevant path rules.

    line 35
  3. Distinctive:

    When no advisory/report was supplied, follow references/automatic-discovery.md.

    line 61
  4. Distinctive:

    Verify the advisory with current primary sources (maintainer/GHSA, vendor security notice, official package or OS advisory).

    line 79
  5. Distinctive:

    Never interpret a list of fixed versions as one global minimum across majors.

    line 82
  6. Distinctive:

    Prefer the smallest compatible fixed release.

    line 90
  7. Distinctive:

    Use the branch's package-manager/Node versions and regenerate its lockfile.

    line 94
  8. Distinctive:

    If no compatible fix exists, report the specific target as blocked and explain whether a larger upgrade or mitigation is available.

    line 98
  9. Very specific:

    Create fix/<cve-or-ticket-slug> from the fetched source base in its own worktree.

    line 105
  10. Distinctive:

    When given an existing commit/PR, inspect its real diff and prerequisites first.

    line 109
  11. Distinctive:

    If a discovered finding affects only a release and no applicable development fix exists, record development as not affected.

    line 116
  12. Very specific:

    Follow the available repository git-ship skill for commit/PR conventions when committing or publishing.

    line 123
  13. Distinctive:

    Commit ancestry/trailers and patch equivalence help find prior backports, but verify the current tree too: an old fix may have been …

    line 134
  14. Distinctive:

    Do not import development-only features, migrations, or prerequisite upgrades unrelated to the fix.

    line 146
  15. Distinctive:

    Never replace the release lockfile wholesale with development's lockfile.

    line 149
  16. Distinctive:

    If a clean cherry-pick still needs release-specific adjustment, add a focused follow-up commit with provenance and explain the adaptation.

    line 154
  17. Distinctive:

    Do not transfer a successful development result to either release.

    line 168
  18. Distinctive:

    Run the relevant test, typecheck, lint, and build checks required by that branch.

    line 175
  19. Very specific:

    After a commit/amend or conflict fix changes content, validate that resulting content before reporting it as ready.

    line 191
  20. Distinctive:

    When push/PR work is authorized, check remote topic branches and existing PRs before creating duplicates.

    line 197
  21. Distinctive:

    Before publication, recheck target remote tips.

    line 204

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fix CVEs and backport to two releases

Discover vulnerabilities when no advisory is supplied, then prepare focused fixes on development and independently validated backports to the two highest numeric release-X.Y branches on the chosen remote. Published releases, tags, commit dates, and local branch availability do not choose targets. Discover the names on every run; never hardcode today's release versions.

Scope and execution

  • Accept CVE/GHSA identifiers, scanner findings, a package/image report, or an existing fix commit/PR. Reuse supplied details and ticket numbers. With no finding supplied, run automatic discovery after establishing branch snapshots; do not ask the user to provide a CVE identifier. With explicit findings, stay within that scope unless the user also requests a broader scan.
  • A request to fix and backport authorizes topic branches, local commits, and cherry-picks. Complete these without another confirmation. A preview/plan-only or scan-only request produces a report without fixes, commits, or publication. Honor explicitly supplied source/target branches.
  • Push and PR creation follow the user's requested scope. If requested, finish them without reconfirming. Otherwise finish with local branches/commits. Never merge, tag a release, publish an image, or push directly to development/release branches as part of this workflow. Topic names start with fix/ or backport/.
  • Keep unrelated edits intact. Work in separate worktrees with unique paths and branches. Inspect existing worktrees before reusing one; never stash, reset, clean, delete, or amend another task's work.

1. Establish branch snapshots

Read the repository's AGENTS.md and relevant path rules. For AI DIAL Chat, read references/ai-dial-chat.md for repository pitfalls. Determine the Git root, intended remote, current worktrees, and working-tree status. Default to origin when it is the repository's upstream; distinguish a fork's push remote from the authoritative remote containing release branches.

For automatic target selection, run the bundled read-only helper:

python3 <skill-directory>/scripts/select_release_branches.py --repo <git-root> --remote <upstream-remote>

It queries the live remote and returns exactly two branch names, full refs, and SHAs. A failure or fewer than two matching branches is a discovery blocker, not permission to use stale local refs or invent a second target. Explain the blocker and continue any independent investigation. Explicit user targets override the automatic selection but still require remote existence/SHA checks.

Fetch the source base and each selected target by explicit branch refspec. Record their fetched base SHAs. Check the selected targets still match the helper's snapshot; if the remote advanced, refresh the snapshot before creating worktrees. Announce the source base and both targets. Use these recorded SHAs for worktree creation and verification. Do not silently change targets midway through a run.

Automatic discovery

When no advisory/report was supplied, follow references/automatic-discovery.md. Scan the source snapshot and both selected release snapshots independently, including development dependencies and the applicable final container images. Collect a baseline queue with advisory IDs, package/artifact locations, branch SHAs, affected/fixed versions, and scanner coverage. A clean development scan does not establish that the releases are clean.

Summarize the queue and continue fixing compatible findings, prioritizing Critical/High severity. Group findings that share the same minimal dependency update; retain every finding's outcome. Do not wait for the user to select a CVE when the request already authorizes discovery, fixes, and backports. Unavailable scanners, incompatible upgrades, and advisories without a fix remain explicit blockers; continue independently actionable work. If discovery finds nothing, report the scanned coverage and gaps without creating empty commits or PRs.

2. Establish the actual fix

Verify the advisory with current primary sources (maintainer/GHSA, vendor security notice, official package or OS advisory). Record the URL, affected package and version ranges, fixed ranges for each maintained line, and finding location. Never interpret a list of fixed versions as one global minimum across majors.

Inspect each branch separately: relevant manifests, every resolved instance in the lockfile, transitive parent chains, overrides, and Docker build/runtime stages. Distinguish an npm dependency, bundled/global npm tool, OS package, and base-image finding; each has a different remediation. A devDependency or missing direct import alone does not prove a false positive.

Prefer the smallest compatible fixed release. Upgrade the owning direct dependency when practical; use a narrow override for a transitive dependency only after checking compatibility. Do not run blanket npm audit fix --force, upgrade unrelated packages, weaken scanner policy, or add suppressions to claim a fix. Use the branch's package-manager/Node versions and regenerate its lockfile. For a source-code fix, add a focused regression test when it can verify the security behavior. Do not create tests that merely assert a dependency version.

If no compatible fix exists, report the specific target as blocked and explain whether a larger upgrade or mitigation is available. A proposed mitigation is not an upstream patch; do not call an unresolved CVE fixed. Continue other targets where safe and independently useful.

3. Produce or identify the source commit

Create fix/<cve-or-ticket-slug> from the fetched source base in its own worktree. Make only the necessary fix and verify it using section 5. Stage explicit paths and commit the security fix, recording the full SHA(s) in dependency order.

When given an existing commit/PR, inspect its real diff and prerequisites first. For a merged PR use the resulting commit(s) on the base branch (including squash SHA), not blindly the original PR head. Isolate the CVE changes when unrelated work is included. For a merge commit establish the correct mainline from its parents/diff or use equivalent ordinary commits; never guess -m 1. An existing sufficient source fix needs no duplicate source commit.

If a discovered finding affects only a release and no applicable development fix exists, record development as not affected. Implement and validate the minimal fix on the newest affected target release, then use its real commit as the source for another affected release when compatible. The originating release already has the fix and needs no cherry-pick of its own commit. Record this provenance; never manufacture an empty development commit or claim a development backport.

Follow the available repository git-ship skill for commit/PR conventions when committing or publishing. Preserve this task's source/target bases, separate worktrees, explicit file staging, and local-only/publish scope: its generic development-base/push examples do not replace these choices. Reuse a known issue number; never invent one. If repository rules require a missing ticket, ask for it while continuing preparation that does not depend on the answer.

4. Backport independently

For each selected release, first inspect the current dependency/code state and history. Classify it as affected, already fixed, not affected, or undetermined. Commit ancestry/trailers and patch equivalence help find prior backports, but verify the current tree too: an old fix may have been reverted. No-op targets need evidence and a report row, not an empty commit/PR.

For an affected target, create backport/<cve-or-ticket-slug>-release-X.Y from its recorded base SHA in a separate worktree, then apply the source commits in order:

git -C <target-worktree> cherry-pick -x <full-source-commit-sha>

Resolve conflicts using the release's existing architecture and dependency line. Do not import development-only features, migrations, or prerequisite upgrades unrelated to the fix. For lockfile conflicts, resolve manifests first, retain the target's unrelated dependency graph, and regenerate with its package manager. Never replace the release lockfile wholesale with development's lockfile. Inspect the resulting dependency changes and unexpected churn before continuing.

For conflicts, stage only resolved task files, continue the cherry-pick, and verify its final message retains (cherry picked from commit <full-source-sha>). If a clean cherry-pick still needs release-specific adjustment, add a focused follow-up commit with provenance and explain the adaptation. When compatibility requires a different patched version, preserve the security outcome, not an identical version string.

An empty cherry-pick is not proof of success: verify the target state before skipping it. If a conflict cannot be resolved confidently, abort only this task's cherry-pick, retain the worktree, and report the blocker while finishing other targets. Repeated tool/push failures require diagnosis, not blind retries or a force-push. On reruns, inspect existing task branches/PRs and reuse valid work; avoid duplicate commits/PRs or overwriting existing branches.

5. Verify each changed branch

Do not transfer a successful development result to either release. In each worktree, read that branch's toolchain, CI checks, and Nx targets before running them. Use the installed workspace tools through its package manager; consult nx-workspace/nx-run-tasks when available.

  • Confirm a reproducible lockfile install and check all affected resolved package copies against the advisory, including transitive/nested copies.
  • Run the relevant test, typecheck, lint, and build checks required by that branch. Use the recorded target base SHA for affected selection, with the candidate committed HEAD. Check wrapper scripts for hardcoded development bases. Follow branch-required full checks when applicable.
  • Re-run the original scanner against the same artifact and finding identifiers. Audit JSON, a lockfile scan, and a final-image scan are different evidence. For container findings, locally build the affected final image(s) and scan those outputs; do not publish them. Check generated production manifests when the build prunes/reinstalls dependencies. Include the requested CVE regardless of severity filters, suppressions, or ignore-unfixed settings.
  • Distinguish a scanner's findings exit status from an execution/auth/network failure. Unrelated pre-existing findings do not imply this CVE is still present; an unavailable scanner does not prove it is gone. Report verification gaps.
  • Review the final diff against that branch's base for scope, compatibility, and lockfile churn. Apply repository review/documentation gates when relevant.

After a commit/amend or conflict fix changes content, validate that resulting content before reporting it as ready. Report passed/failed/unavailable checks explicitly; do not label a partially verified backport fully verified.

6. Publish if requested and report

When push/PR work is authorized, check remote topic branches and existing PRs before creating duplicates. Push only the task's topic refs. Set each PR's base explicitly: source PR to development (or the chosen source base), backport PRs to their respective release branches. Use repository PR templates and include CVE links, source SHA/PR, branch-specific versions, adaptations, and check results. Respect requested draft status; use draft PRs for known verification gaps.

Before publication, recheck target remote tips. If a target moved, inspect the intervening changes and refresh/revalidate the candidate as needed; never imply validation was performed against a newer base. Stop a rejected push for diagnosis; do not force-push or bypass branch protection. Do not claim CI passed without observing it; use monitor-ci when CI monitoring is requested.

Finish with a compact table for the source and both targets: base branch/SHA, outcome (fixed / already fixed / not affected / blocked), topic branch and commit SHA(s), validation results, and PR link if created. Include worktree paths for local work and exact remaining blockers. A blocked or unverified target means the overall task is partial, even if the other branches succeeded. For automatic discovery, also report baseline finding outcomes and scan coverage per branch/artifact, including unfixed, suppressed, and unverified findings.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.