Skip to content

fix(osint): use team_handle query_string and route lookup progress to stderr in h1_reference.py - #202

Closed
flipcyde101 wants to merge 1 commit into
elementalsouls:mainfrom
flipcyde101:fix/h1-reference-program-filter
Closed

flipcyde101 wants to merge 1 commit into
elementalsouls:mainfrom
flipcyde101:fix/h1-reference-program-filter

Conversation

@flipcyde101

Copy link
Copy Markdown

What does this change?

Fixes #201 in skills/offensive-osint/scripts/h1_reference.py:

  • Replaces the broken terms: {team_id: [...]} filter in build_page_query() with query_string: "team_handle:<handle>" (preserving total_count, endCursor pagination, GraphQL escaping, and optional sort flags).
  • Routes lookup_program()'s [+] <handle> → id=... progress output to sys.stderr so --json stdout stays clean and directly parseable (also unblocking dashboard.py when filtering by program), and guards against data: null GraphQL responses.
  • Rejects empty/whitespace-only --program values cleanly before making network requests, and adds mocked unit tests with synthetic data in tests/test_h1_reference.py.

Type

  • Improvement to an existing skill
  • Tooling / scripts / CI

Checklist

  • No client/engagement data — no real target names, account UIDs, endpoints, bounty amounts, credentials, or PII. All examples are class-based / anonymized.
  • python3 scripts/lint_skills.py passes locally (frontmatter, name, description length, identifier/secret scan).

Anything reviewers should know?

  • All 14 new unit tests in tests/test_h1_reference.py mock urllib.request.urlopen with synthetic handles/reports only (no network access).
  • Verified locally (and independently re-run): python -m unittest discover -s tests (79/79 OK), python scripts/lint_skills.py (0 errors), and python scripts/scan_identifiers.py (341 files, 0 matches).

@auditbenchaibot auditbenchaibot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open in Audit Bench Ai

🤖 Automated review by Audit Bench Ai, not a personal review. It was posted through the GitHub account connected to Audit Bench Ai. Install the Audit Bench Ai GitHub App to have reviews posted by a separate bot account.

No actionable comments were generated in this review. 🎉

Merge risk: 🟢 Low · up to b605d68

Risk is low because changes are well-tested with mocked HTTP calls and fallback behavior for unauthenticated queries remains intact.

Merge readiness: 🟡 Ready to merge, with notes

Pre-merge checks: ✅ 9 · ⚠️ 1

⚠️ Checks to review: 1 warning

Check name Status Explanation Resolution
CI checks ⚠️ No CI checks ran on this commit. Add CI so every PR is built and tested.
✅ Passed checks: 9 passed
Check name Status Explanation
Merge conflicts ✅ Merges cleanly into main.
Secrets ✅ No keys, passwords or tokens in the changed code.
Blocking issues ✅ No critical or high-severity issues in the changed lines.
Tests ✅ Tests were changed alongside the code.
PR size ✅ 342 lines changed.
Title check ✅ The title clearly and concisely describes the main changes made in the PR.
Description check ✅ The description provides detailed context on the problem, the fix, and testing verification.
Linked issues check ✅ The PR addresses issue #201 by updating the query filter and routing logs to stderr.
Out of scope changes check ✅ All changes directly relate to fixing program filtering and its associated unit tests.
📝 Walkthrough

This pull request fixes HackerOne program filtering in h1_reference.py by using query_string: "team_handle:" instead of the unsupported team_id terms filter. It routes program lookup progress messages to stderr to keep stdout clean for JSON parsing, and handles null responses safely. A comprehensive suite of synthetic unit tests is also added to verify the changes without network access.

File Changes
skills/offensive-osint/scripts/h1_reference.py Switches to query_string team_handle filtering, directs lookup logs to stderr, and validates empty program inputs.
tests/test_h1_reference.py Adds unit tests covering query generation, stderr logging, pagination, and sorting using mocked responses.
ℹ️ Review info
  • Commit: b605d68
  • Verdict: ✅ Pass
  • Findings: none
  • Review: local checks plus AI review of the changed lines
  • Scope: Reviewed 2/2 selected files (of 2 total): 2 reviewed by AI, 0 from cache, 0 passed local checks with nothing risky enough to send to AI. Found 0 finding(s), No secrets found.

💬 Reply to any inline comment and Audit Bench Ai will recheck that code and answer in the thread. Mention @auditbench in the conversation to ask about the whole PR.

🛠️ Open the full report and fix with AI

Thanks for using Audit Bench Ai! Free pull request reviews for open source: paste any public PR at auditbenchai.com/scan.

Reviewed by Audit Bench Ai · Build fast. Check what ships. · Review any public PR free

roonnnnyyyyyy added a commit to roonnnnyyyyyy/Claude-BugHunter that referenced this pull request Nov 22, 2026
…stderr

Fixes elementalsouls#202

- Replace deprecated `terms: {team_id: [...]}` filter in `build_page_query()` with `query_string: "team_handle:<handle>"` to match the current HackerOne GraphQL schema.
- Route the `[+] <handle> → id=...` status message in `lookup_program()` to `sys.stderr` so `--json` stdout remains valid and pipeable (e.g., to `jq`).
elementalsouls added a commit that referenced this pull request Nov 22, 2026
…CRLF, Windows console, h1 --program (#210)

* fix(cbh): triage gate — real request-target for Q1, scope-negation for Q3, clickjacking for Q7

Three false-verdict paths in the 7-Question Gate, each independently reported:

- Q1 matched a bare method word anywhere in the text, so prose like
  "target application" (contains "get ") or "input validation" passed Q1
  with no request at all. Q1 now needs a method followed by a path or URL
  (or curl / HTTP/1.1). Reported by @dajiaohuang (#209).
- Q7's never-submit list had "click-jacking" but not "clickjacking", so the
  unhyphenated spelling was never killed. Reported by @Ethereal49 (#197).
- Q3 answered YES on any scope/asset wording even when the finding itself
  said "out of scope" / "unverified". A scope/asset line carrying a negation
  no longer counts as in-scope evidence; non-scope lines ("Impact: unclear")
  still don't. Reported by @Ethereal49 (#197).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cbh): parse finding frontmatter through a leading UTF-8 BOM

A BOM (\ufeff) written by some Windows editors sits before the `---` fence,
so the `^---` frontmatter regex missed it and severity/asset fell back to
defaults. Strip a leading BOM in parse_finding_metadata, the shared chokepoint
for every command that reads a finding, not just `cbh report`.

Reported by @jazzpher (#200).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cbh): force UTF-8 stdout so Windows cp1252 consoles don't crash

cbh and setup_harness_mcp.py print the gate glyphs (check / cross / arrow /
em-dash) throughout. On a Windows console (cp1252) a bare print() raised
UnicodeEncodeError and the command died mid-run. Reconfigure stdout/stderr to
UTF-8 at both entrypoints, the same fix engine/engine.py:main already uses, so
the whole CLI is covered at one point rather than guarding every print.

Reported by @Sahilkumar-r (#180).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(offensive-osint): filter h1_reference --program by team_handle, not team_id

CompleteHacktivityReportIndex no longer accepts terms: {team_id: ...}, so
--program silently returned nothing. Switch to query_string "team_handle:<h>",
which filters correctly and still accepts sort + pagination (so --program now
composes with --top-voted / --top-bounty). Also: route the lookup progress line
to stderr so --json stdout stays pipeable, and reject an empty --program handle.

Two independent reports converged on this fix: @roonnnnyyyyyy (#206) and
@flipcyde101 (#202).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(changelog): record the four tooling bugfixes with reporter credits

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cbh,osint): review follow-ups — Q3 negation, Q1 markdown, CRLF, canonical handle

Adversarial review of the branch surfaced five real defects:

- Q3 _q3_scope_negated matched ANY line containing 'scope' plus a negation,
  so 'Impact: unclear scope of data exposure' wrongly killed an in-scope
  finding. Negation is now evaluated per line: strong phrases ('out of scope')
  disavow anywhere; weak words ('unknown','unclear') only on a scope/asset/
  target line (the key before the colon).
- Q3 negation list was space-only, so the common hyphenated 'out-of-scope'
  slipped through. Hyphens are normalized to spaces before matching.
- Q1 required whitespace between method and path, missing the markdown a PoC
  is usually written in (`GET /x`, **GET** /x, GET `/x`). The separator class
  now allows backticks and bold/italic markers. The prose ceiling
  ('an attacker can get /admin') is marked, not closed — requiring HTTP/ would
  reject the bare 'GET /path' PoC the gate must accept.
- parse_finding_metadata now also normalizes CRLF, so Windows findings (the
  same platform as the BOM in #200) don't skip frontmatter.
- h1_reference --program queried the raw input handle; query_string is
  case-sensitive while TeamLookup is not, so '--program Shopify' could return
  nothing. lookup_program now returns the team record and main uses the
  canonical handle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@elementalsouls

Copy link
Copy Markdown
Owner

Thanks @flipcyde101 — your fuller version (sort support, empty-handle guard, test coverage) is what the in-house fix is based on. Landed in 9ba66b1 (#210): query_string:"team_handle:<canonical>", canonical-handle resolution, stderr progress. Converged with @roonnnnyyyyyy's #206; both credited in CHANGELOG. Closing as built-in-house.

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.

[bug] h1_reference.py: --program filter broken (team_id no longer searchable); --json output polluted

4 participants