Skip to content

feat(shodan): add TTP mapping and argumentType on ip/vulnerability fields (#405) - #411

Merged
Samuel Hassine (SamuelHassine) merged 4 commits into
mainfrom
feat/shodan-ttp-mapping-and-argument-type
Aug 4, 2026
Merged

Samuel Hassine (SamuelHassine) merged 4 commits into
mainfrom
feat/shodan-ttp-mapping-and-argument-type

Conversation

@Seb-MIGUEL

@Seb-MIGUEL Sébastien MIGUEL (Seb-MIGUEL) commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #405

  • contract_attack_patterns_external_ids=["T1596.005"] (Search Open Technical Databases: Scan Databases) on all 7 shodan contracts.
  • argumentType=PrimitiveType.IPv4 on the "IP" field (ip_enumeration) - picked as the practical default since PrimitiveType carries one value per field and Shodan's IP-typed outputs are overwhelmingly IPv4; an IPv6 finding will not auto-link here (flagged rather than silently assumed).
  • argumentType=PrimitiveType.CVE on the "Vulnerability" field (cve_specific_watchlist) - it holds a CVE id despite the generic label.
  • hostname/organization/custom_query stay text: hostname's fit needs confirming (the internal trace config calls it plural "hostnames" - one value or a CSV list?), organization has no org-shaped finding produced anywhere today, custom_query is a raw query-language string.
  • Regression tests: test_argument_type.py pins the two typed fields; test_ttp_mapping.py asserts every built contract carries exactly ["T1596.005"] (added following review).

Test plan

  • pytest tests/ - 31/31 passing locally, Test shodan green in CI

Notes

…elds

- contract_attack_patterns_external_ids=["T1596.005"] (Search Open
  Technical Databases: Scan Databases) across all 7 contracts.
- argumentType=PrimitiveType.IPv4 on "IP" (ip_enumeration) — picked as
  the practical default since PrimitiveType carries one value per
  field and shodan's own IP-typed outputs are overwhelmingly IPv4; an
  IPv6 finding won't auto-link here, flagged rather than silently
  assumed.
- argumentType=PrimitiveType.CVE on "Vulnerability"
  (cve_specific_watchlist) — holds a CVE id despite the generic label.
- hostname/organization/custom_query stay text: hostname's fit needs
  confirming (internal trace config calls it plural "hostnames" — is
  it really one value or a CSV list?), organization has no
  org-shaped finding produced anywhere today, custom_query is a raw
  query-language string.

Part of #405, see docs/specs/2026-08-input-and-output-typing.md and
docs/specs/2026-08-ttp-mapping.md.
Copilot AI lite review requested due to automatic review settings August 4, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Shodan injector’s contract metadata to support the platform rollout for (1) input argument typing (for chaining) and (2) MITRE ATT&CK technique mapping, as tracked by #405.

Changes:

  • Add argumentType typing to the Shodan ip_enumeration.ip field (PrimitiveType.IPv4) and cve_specific_watchlist.vulnerability field (PrimitiveType.CVE).
  • Add contract_attack_patterns_external_ids=["T1596.005"] to all 7 Shodan contracts.
  • Add a focused test validating the new argumentType values on the two affected fields.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
shodan/tests/shodan_contracts/test_argument_type.py Adds tests asserting argumentType is set for the IP and vulnerability inputs.
shodan/shodan/contracts/ip_enumeration/contract.py Types the ip input as PrimitiveType.IPv4 and adds TTP mapping on the contract.
shodan/shodan/contracts/cve_specific_watchlist/contract.py Types the vulnerability input as PrimitiveType.CVE and adds TTP mapping on the contract.
shodan/shodan/contracts/domain_discovery/contract.py Adds contract_attack_patterns_external_ids mapping to the contract.
shodan/shodan/contracts/cve_enumeration/contract.py Adds contract_attack_patterns_external_ids mapping to the contract.
shodan/shodan/contracts/custom_query/contract.py Adds contract_attack_patterns_external_ids mapping to the contract.
shodan/shodan/contracts/critical_ports_and_exposed_admin_interface/contract.py Adds contract_attack_patterns_external_ids mapping to the contract.
shodan/shodan/contracts/cloud_provider_asset_discovery/contract.py Adds contract_attack_patterns_external_ids mapping to the contract.

Comment thread shodan/tests/shodan_contracts/test_argument_type.py
#405)

- add a regression test asserting every shodan contract carries T1596.005
  (requested by the Copilot review comment)
- drop a dangling docs/specs reference from the argumentType test docstring
- tighten the ip_enumeration argumentType comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the full changed files independently and drove the follow-up fixes on the branch. The TTP choice (T1596.005, Search Open Technical Databases: Scan Databases) is the canonical technique for Shodan queries and fits all 7 contracts; the two argumentType picks (IPv4 on ip_enumeration, CVE on cve_specific_watchlist) are correct against pyoaev PrimitiveType, and the fields deliberately left as text are well justified in the description. A TTP regression test now pins the mapping across all contracts. Test shodan, linter and ensure_formatting are green; the Test nuclei failures are external to this PR (client-python main added ContractElement.argumentType, which changed serialized contract JSON and broke nuclei exact-payload sync tests on every branch; the fixture update lands with PR #410). Approving.

@SamuelHassine

Copy link
Copy Markdown
Member

Review and fix summary

Fixes pushed (f5dba26, signed):

  • Added tests/shodan_contracts/test_ttp_mapping.py: builds the full contract set and asserts every contract carries exactly ["T1596.005"] (addresses the Copilot review comment; mirrors the stratus TTP test precedent).
  • Removed a dangling reference to a non-existent docs/specs/ file from the test_argument_type.py docstring.
  • Tightened the argumentType comment in ip_enumeration/contract.py.

Review threads: 1 inline comment (Copilot) - implemented, replied, resolved. 0 unresolved threads remain.

Verification: 31/31 tests pass locally and in CI (Test shodan green). Black/isort/flake8 clean on the touched files. PR title matches the repo convention and the description was re-flowed to reflect the final state.

Remaining blocker (external): Test nuclei and ci/circleci: test-nuclei fail on every branch of this repo since client-python main added ContractElement.argumentType (changed serialized contract JSON, breaking nuclei exact-payload sync tests). The nuclei fixture update lands with PR #410; once merged, a rebase or re-run turns this PR fully green. Nothing in this shodan-only diff can or should fix it. CLA check is green (organization member).

@SamuelHassine
Samuel Hassine (SamuelHassine) merged commit 79060e6 into main Aug 4, 2026
44 checks passed
@SamuelHassine
Samuel Hassine (SamuelHassine) deleted the feat/shodan-ttp-mapping-and-argument-type branch August 4, 2026 18:05
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.

feat: rollout input argument typing and action_output across ai-redteam, aws, http-query, netexec, nmap, nuclei, shodan, stratus

4 participants