Skip to content

fixing output writing#2462

Open
Mzack9999 wants to merge 1 commit intodevfrom
2418-store-response-only-matched
Open

fixing output writing#2462
Mzack9999 wants to merge 1 commit intodevfrom
2418-store-response-only-matched

Conversation

@Mzack9999
Copy link
Copy Markdown
Member

@Mzack9999 Mzack9999 commented Mar 22, 2026

Proposed changes

Close #2418

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Improvements

    • Optimized response persistence logic: when matchers or filters are active, response storage is now deferred to the output loop instead of being written immediately, improving efficiency.
  • Tests

    • Added comprehensive test coverage for matcher and filter detection, including scenarios with and without active filters.

@auto-assign auto-assign bot requested a review from dogancanbakir March 22, 2026 12:35
@neo-by-projectdiscovery-dev
Copy link
Copy Markdown

neo-by-projectdiscovery-dev bot commented Mar 22, 2026

Neo - PR Security Review

No security issues found

Highlights

  • Introduces HasMatcherOrFilter() method to control when HTTP responses are written to disk
  • Adds logic to defer file writing when matchers/filters are active, ensuring only matched responses are stored
  • Includes comprehensive test coverage for the matcher/filter detection logic
Hardening Notes
  • Consider validating URL.Host more strictly before using it in filepath.Join at runner.go:1308 - while URL parsing prevents most path traversal, explicit validation that hostFilename does not contain '..' or path separators would add defense in depth
  • File permissions 0644 at runner.go:1333 and runner.go:1344 allow group/world read - consider using 0600 if response files may contain sensitive data

Comment @pdneo help for available commands. · Open in Neo

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1219100d-3d31-4370-b4d4-69b6b322b2da

📥 Commits

Reviewing files that changed from the base of the PR and between 9836829 and 3adf9ce.

📒 Files selected for processing (3)
  • runner/options.go
  • runner/runner.go
  • runner/runner_test.go

Walkthrough

A new HasMatcherOrFilter() method was added to detect when matcher or filter options are active, and response persistence logic was modified to defer file writing to the output loop when matchers/filters are enabled, ensuring only filtered responses are stored to disk.

Changes

Cohort / File(s) Summary
Matcher/Filter Detection
runner/options.go
Added HasMatcherOrFilter() method to check if any matcher or filter option is set across string fields, parsed slices, and other configuration flags.
Response Persistence Logic
runner/runner.go
Modified file writing logic to skip immediate disk writes when matchers/filters are active; defers persistence to output loop. Consolidated fileNameHash computation and refined file creation retry loop with os.O_EXCL handling.
Test Coverage
runner/runner_test.go
Added three test functions: TestOptions_hasMatcherOrFilter validates the detection method across all matcher/filter options; TestStoreResponse_withoutMatchersStoresAll and TestStoreResponse_withMatcherSetsFlag verify interaction between response storage and matcher/filter state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit hops through files with glee,
"Now responses match with selectivity!
No more saving all with a careless sweep,
Only treasures that matchers keep!"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and non-descriptive. 'Fixing output writing' does not clearly convey the main change of storing responses only for matched requests rather than all responses. Consider using a more specific title like 'Store responses only for matched requests' to better describe the primary change and its purpose.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request adds HasMatcherOrFilter() method and adjusts response persistence logic to store responses only when no matchers/filters are active, directly addressing issue #2418's requirement.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue: HasMatcherOrFilter() detection, conditional response persistence, and comprehensive test coverage for the new functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2418-store-response-only-matched

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

how to sr (only match)

1 participant