Skip to content

Commit e21bc87

Browse files
meysholdtona-agent
andcommitted
Merge analyze + fix agent prompts into one step per automation
Co-authored-by: Ona <no-reply@ona.com>
1 parent 2b048b3 commit e21bc87

2 files changed

Lines changed: 19 additions & 58 deletions

File tree

.ona/fix-codescan-alert.yaml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,16 @@ action:
2727
cat /tmp/codescan-alert.json
2828
- agent:
2929
prompt: |
30-
Read the file /tmp/codescan-alert.json which contains the highest-severity
31-
open code scanning alert for this repository.
32-
33-
From the alert, extract:
34-
1. Alert number and HTML URL
35-
2. Rule ID and description
36-
3. Severity level
37-
4. File path and line number (from `most_recent_instance.location`)
38-
5. The tool that reported it (CodeQL, Trivy, OSV-Scanner, etc.)
39-
6. The alert message
40-
41-
Read the affected source file and surrounding context to understand the issue.
42-
43-
If the alert is about a vulnerable dependency (from Trivy or OSV-Scanner),
44-
identify the dependency, its current version, and the fixed version from the
45-
alert details.
46-
47-
Do NOT make any code changes yet.
48-
49-
- agent:
50-
prompt: |
51-
Using the alert identified in the previous step, apply the fix:
52-
53-
**For code quality / CodeQL alerts:**
54-
1. Apply the minimal code change that resolves the alert.
55-
2. Follow the project's code style and conventions.
56-
3. If the alert suggests a specific fix pattern, follow it.
57-
58-
**For dependency vulnerability alerts (Trivy / OSV-Scanner):**
59-
1. Upgrade the vulnerable dependency to a patched version.
60-
2. If the version is inherited from a parent BOM, add an explicit
61-
version override in `pom.xml` properties or `<dependencyManagement>`.
30+
Read /tmp/codescan-alert.json which contains the highest-severity open
31+
code scanning alert. Extract the alert number, HTML URL, rule ID, severity,
32+
file path and line number, tool name, and message.
33+
34+
Then apply the fix:
35+
- **CodeQL alerts:** Apply the minimal code change. Follow the project's
36+
code style. Use the suggested fix pattern if one is provided.
37+
- **Dependency alerts (Trivy / OSV-Scanner):** Upgrade the vulnerable
38+
dependency to a patched version. If inherited from a parent BOM, add
39+
an explicit version override in `pom.xml`.
6240
6341
Do NOT commit or run tests yet.
6442

.ona/fix-dependabot-alert.yaml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,16 @@ action:
2727
cat /tmp/dependabot-alert.json
2828
- agent:
2929
prompt: |
30-
Read the file /tmp/dependabot-alert.json which contains the highest-severity
31-
open Dependabot alert for this repository.
30+
Read /tmp/dependabot-alert.json which contains the highest-severity open
31+
Dependabot alert. Extract the alert number, package name, vulnerable and
32+
patched versions, CVE ID, CVSS score, and manifest file path.
3233
33-
From the alert, extract:
34-
1. Alert number
35-
2. Package name and ecosystem
36-
3. Vulnerable version range
37-
4. Patched version (from `security_advisory.vulnerabilities[].first_patched_version`)
38-
5. CVE ID and CVSS score
39-
6. Advisory summary
40-
7. The manifest file path (e.g. `pom.xml`)
41-
42-
Read the manifest file to understand how the dependency is declared.
43-
Determine whether the version is pinned directly or inherited from a parent BOM.
44-
45-
Do NOT make any code changes yet.
46-
47-
- agent:
48-
prompt: |
49-
Using the alert identified in the previous step:
50-
51-
1. Upgrade the vulnerable dependency to the patched version (or newer).
52-
- If the version is declared in `pom.xml` properties or directly, update it there.
53-
- If it is inherited from a parent BOM (e.g. Spring Boot parent), check whether
54-
upgrading the parent resolves the vulnerability. If not, add an explicit
55-
version override in the `<properties>` or `<dependencyManagement>` section.
56-
2. Follow the project's existing conventions for dependency management.
34+
Then apply the fix:
35+
1. Read the manifest file to understand how the dependency is declared.
36+
2. Upgrade the vulnerable dependency to the patched version (or newer).
37+
- If the version is in `pom.xml` properties or directly, update it there.
38+
- If inherited from a parent BOM, add an explicit version override.
39+
3. Follow the project's existing conventions.
5740
5841
Do NOT commit or run tests yet.
5942

0 commit comments

Comments
 (0)