Improve first thought - #291
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
zvigrinberg
left a comment
There was a problem hiding this comment.
@RedTanny Thank you for the PR.
Please see my comments.
|
/retest |
|
Caution There are some errors in your PipelineRun template.
|
|
/test vulnerability-analysis-on-pr |
|
Just FYI, with the multi-prompting framework coming, these prompts will be moved to centralized locations, with separate copies per model and if necessary, per environment (I know of Java-specific prompts for certain tool usage chains). So please be aware of this coming change, and a big rebase/merge. |
@etsien But the RPM analysis is out of scope for multi repo... ( this could be a future enhancement POST-GA that if the TPA guys wants to prioritize it will happen). So it's expected to be quite smooth rebase. |
… and llm didn't follow prompt less accurate
Implements issues 01-06 of intel gathering refactor: - FileChangeSummary model and extraction (01) - file_changes span output (02) - CVE_UNDERSTANDING_PROMPT (03) - PATCH_ANALYSIS_PROMPT (04) - IntelGatheringResult object (05) - Dual-path intel gathering with enable_new_intel_flow config (06) Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2601f5a to
97f5d75
Compare
…l LLM calls. Steer forced-finish and empty-grep from FILE_CHANGES/identify signals, keep focused patch context out of NEW OUTPUT, and avoid cartesian comprehension that overflowed context on large single-file diffs. Co-authored-by: Cursor <cursoragent@cursor.com>
| "Intercepted an error from tool", | ||
| ) | ||
| # Source Grep query: pattern[,file_filter] — last comma segment is the file filter. | ||
| GREP_QUERY_FILE_SEPARATOR = "," |
There was a problem hiding this comment.
@RedTanny Maybe this one and GREP_QUERY_FILE_SEPARATOR of cve_package_code_agent.py could be the same one ( impore it there from here)?
There was a problem hiding this comment.
| # Fallback: compute target_version_in_vulnerable_range from NVD if not set by Identify phase | ||
| if vulnerability_intel.target_version_in_vulnerable_range is None and fixed_ver: | ||
| try: | ||
| from packaging import version as pkg_version |
There was a problem hiding this comment.
@RedTanny Are you sure it's the appropriate lib ( packaging.version) to compare the versions? AFAIK it's only tailored to python versions as per PEP-440.
There was a problem hiding this comment.
| normalized_line = _normalize_pattern_text(line) | ||
| if not normalized_line: | ||
| return False | ||
| return pattern in normalized_line or normalized_line in pattern |
There was a problem hiding this comment.
@RedTanny IMO It's too much permissive, it allows, for instance , to generic pattern like write to pass through if the line contains a much more specific method/function, like write_in_spool_if_ack , but it's clear that there is no affinity at all between these two.
There was a problem hiding this comment.
- Added test_l1_file_changes_step1_prompt.py to verify Step-1 prefers highest-removal FILE_CHANGES file - Added test_l2_kernel_makefile_pattern_prompt.py to verify L2 kernel Makefile grep uses path tokens Co-authored-by: Cursor <cursoragent@cursor.com>
- Added test_l1_intel_grep_guard.py to verify intel allowlist validation - Tests cover hallucinated grep patterns, allowed substrings, and file filter scopes Co-authored-by: Cursor <cursoragent@cursor.com>
zvigrinberg
left a comment
There was a problem hiding this comment.
@RedTanny LGTM Approved , Great job.
Thank you.
Summary
Refactors L1 intel gathering so the checker extracts CVE understanding and patch intel separately (per-file), then feeds focused context into Source Grep observations. Also includes related checker bugfixes and OSIDB identify improvements from this branch.
Why
The old single-prompt intel extraction mixed CVE narrative with full-patch analysis, which hurt keyword quality on large patches and gave observations little file-specific guidance. Splitting the flow improves search targeting and keeps large patches within the context budget.
High-level feature (intel refactor)
IntelGatheringResultaggregates per-file intel and converts back toVulnerabilityIntelfor existing prompts/reportsTesting
Added unit coverage for the refactor and related empty/error tool handling:
test_file_change_summary.py— patch → per-file summaries / token estimatestest_cve_understanding_prompt.py— Prompt 1 formatting and keyword rulestest_patch_analysis_prompt.py— Prompt 2/3 formatting and functions summary helpertest_intel_gathering_result.py— lookup, aggregation, focused-context formattingtest_new_intel_flow.py— file priority + token-budget batch splittest_focused_observations.py— file filter extraction + focused context injectiontest_check_empty_output.py— tool-error detection via status/prefix (not mid-content"error:")tests/test_package_identifier.py— OSIDB affectedness / identify regression coverageBug fixes
b31b9d9): advisory/OSIDB URLs were missed when mining commit/advisory links for intel.8ab9421): weak reference hints no longer keep searching repos; flow goes to the agent instead.cafce28): removed extra prompt/intel fields that added noise and made the LLM less reliable.47f8c01): dropped confusing “Patch file:” labeling from the checker report viewer.6c0576d): clarified grep tool instructions/schema so the LLM calls Source Grep correctly.4132d2b): fixed PackageIdentifier affectedness regression after OSIDB support.Also in this branch
PackageIdentifier(55ac04d)"error:"in source are not treated as tool failuresTest plan
Initial_Intelligence_Gatheringshowsfile_changes+ CVE understandingfocused_context_used=true