Skip to content

Update trajan to 1.0.2 - #3669

Merged
liquidsec merged 1 commit into
devfrom
update-trajan
Nov 20, 2026
Merged

liquidsec merged 1 commit into
devfrom
update-trajan

Conversation

@blsaccess

Copy link
Copy Markdown
Contributor

This PR uses https://api.github.com/repos/praetorian-inc/trajan/releases/latest to obtain the latest version of trajan and update the version in bbot/modules/trajan.py.

Release notes:

Changelog

  • c0dc84debc2066addd64baf5f07b6a567b6ac39a Add Claude PR Assistant workflow
  • 2bbae97ef0cb7fae197857b489eac3f3ecf1ddef Add missing Remediation fields to GitHub detection findings
  • 1c181894384ea36a87c5499272730064731ea5c0 Add missing user-controllable GitHub context paths to taint sources
  • 7aa98e4112e188e841f58986630597225c16087c Fix generic/self-referential remediation messages in detections
  • 981d012e2fcc97fbf757bfdd902df55078e2bc7b Fix missing WorkflowFile field across detection plugins
  • 90694136ae9c008011ed8a2d3532663944b825ea Merge main into chore/external-contrib-v2.0.2 (resolve conflict: keep v2.0.2 + explicit secrets)
  • 1954928f0d16805f03f6e4973b724cc42cdf3662 Merge remote-tracking branch 'origin/main' into chore/harden-claude-code-v2.0.2
  • e4e89bc13ebb1a605eb0bdb20c4cc8a129d68f52 Revert README roadmap overhaul and section rename
  • e0aec17c15ccbdff5ec2b884c2ec5b43df006138 Update image in README with new dimensions and source
  • 12db0b496711dfa37023330d9985ad8194d364be chore(ci): bump claude-md-drift reusable to v2.6.5 (max_turns 10->20) (Cloud Helpers #56)
  • 2521ffbc2b1bc39ad4e6a39b942d812057bd7afa chore(ci): bump public-workflows pin to v2.0.10 (135c500)
  • 4203024ef774a59e023f504bd898170d88c6f63a chore(ci): bump public-workflows pin to v2.0.10 (135c500)
  • 8288df19a35f62f1b3465cf1e649782eede2737d chore(ci): bump public-workflows pins to v2.0.11 (e7c1f39)
  • bcc867b46aabb6b4129ada7f5622d7038c242e74 chore(ci): bump public-workflows pins to v2.9.3 (org-wide preflight fix) (Recursive Wildcard Bug #62)
  • be32481678b3a836a347428dab23da5483a4e4e7 chore(ci): bump public-workflows to v2.0.13 (HackRedCon Pre-Talk Release #29)
  • a8167e40d458498bd547cbeadcd16384a67ca69f chore(ci): converge go-ci reusable -> v2.6.6 (Update issue templates #58)
  • cba78ed861feb07b463c5cd581242aee3a0cdd63 chore(ci): harden claude-code workflow (pin SHA v2.0.2 + read-only + concurrency)
  • 2692b1d9cc03cb5aa1ee188da593305c3a756ee8 chore(ci): pin codex-code.yml to public-workflows v2.1.1 (Fixed bug in scope distance calculation for new events #30)
  • a8ba4a7067711e12a8aa6f9b7c67abc7b07828af chore(ci): re-bump public-workflows pin v2.0.4 → v2.0.5 (fix author_association skip bug)
  • 8ae43650b4fdf7e2d75082deddf1c740a4a5c718 chore(ci): re-bump public-workflows pin v2.0.5 → v2.0.6 (fix author_association quirk on public repos)
  • abc8fb1e9a5e5fcf9e952af82cff8dfb81119e14 chore(ci): re-bump public-workflows pin v2.0.6 → v2.0.8 (cost opt: Opus + first-open + no MCP + simpler prompt)
  • de1adf4e5c1da453e7ced5803333f247dc9936f9 chore(ci): re-bump public-workflows pin v2.0.8 → v2.0.9 (preflight docs-only + Harden-Runner)
  • 977253a14e758337ef5abefdfae3c42b64eb057c chore(ci): sweep public-workflows pins to v2.0.10 (135c500)
  • 4dc54de03d6755f18f4608b43b4dfb182e9b5421 chore(claude-code): bump public-workflows SHA to include ready_for_review fix (Wildcard fix, temporarily remove aspnet_viewstate module #26)
  • b78f4990dc745221001538fe3a7a28553b18ab08 chore(deps): upgrade google.golang.org/grpc to v1.81.1
  • 003839df5ed6570a901d35f8f3425df54772e43e chore(lint): fix 9 mechanical golangci-lint v2 findings
  • ad1932fb678bcfb8daca6a57b2df4f63402688b6 ci(claude): bump claude-code reviewer to public-workflows v2.11.3 (Performance Optimizations #66)
  • c4e3a9382155c1f0c90b6b5e55fb82bd6f13a2a9 ci(codex): bump public-workflows pin f7fb4810ccab4ab589499b632fb61983124ece79 -> v2.6.0 (byte-identical, hygiene) (Automate Traceback Logging #52)
  • f83d42bc7b5a2c8bacfd215912bb6bcc8d7fb731 ci(codex): bump public-workflows pin to v2.4.0 (Fix Intermittent Dependency Caching Issue #46)
  • 8d965be35169f9aa21da75f05fd2a067c21b482b ci(codex): bump reviewer model to gpt-5.5 (Dependency Caching Sometimes Doesn't Work #45)
  • a22fe46adc9cf7df01ab7f1c84cbfb646c6f6db2 ci(graphify): add code knowledge graph workflow (Merging in Template for Bug Reports #61)
  • a5e9fbd82d7a6cd992dcaa37f917302ed11afddc ci: bump claude-code.yml reusable pin v2.1.0 -> v2.5.1 (Add config option for DNS retries, lower default DNS timeout from 10 to 5 seconds #49)
  • df650649a76c7c9e10893ae18ce46c450c4a747a ci: bump codex/gemini reviewers to public-workflows v2.11.3 (Fix Pypi Auto-Publishing #64)
  • 840554b59ed6b87a2b409f6ffbbef7d5a3a7df08 ci: disable dry-run for live external-contrib notifications
  • 3fee11a732459abfaf77b3f4a9efba9cde0ca150 ci: migrate external-contrib to centralized reusable (v2.0.2)
  • 18ccd94a20d43fb4473093b95167fef37c3caa0c ci: migrate external-contribution.yml to centralized reusable workflow
  • 015cf239ac8640bf1b9f10805544149e423e9fa5 ci: migrate to centralized go-ci.yml reusable workflow (ENG-3081)
  • c4647f3a9484a8ea1b91ffbe27e203ac5c76a2c5 ci: pin claude + gemini reviewers to public-workflows v2.6.0 (Wildcard Detection Intermittently Fails for Anycast DNS #54)
  • 1b3fd4cd1f69f818229c913d80370836eb6183b3 ci: stop stray review comments cancelling in-progress AI reviews (Updating Issue Template #59)
  • 322fa208c2cda0d27a871c630ea4d74313cf1fd3 ci: trigger release on tag push (v*) instead of every commit to main
  • d11adb34e566db867386f76e4d59965a8b6c3074 cleanup: fix stale severity comments in ADO, Bitbucket, GitLab AI tests
  • 8973ec960309a5f353d67b69e2af5ab38bc5dabc cleanup: fix stale severity comments in GitHub AI detection tests
  • 8653adf3e70308da2f19fa71e98293834c0e291c cleanup: unify --list output format across platforms
  • 92ca4cbb980cf9a79d8e97cf098a567e4a65e83f feat(bitbucket): add enumerate token command for Bitbucket Cloud
  • 837996029b937cb85a22eab780db1ef6c468e7bf feat(ci): add CLAUDE.md drift detection via centralized reusable (Unable to Start Scan if tldextract Fails to Download Data #38)
  • 0a3418b59096408bd64cdaf16e2da417a328f943 feat(ci): add Titus secrets scanning (Gowitness Module Incompatible with Ubuntu #34)
  • eb1c53dd1df850e33af8a34673474091d45bd472 feat(github): adapt c2-setup attack for ghs_ tokens
  • 042528e08ad19fc3ac95074b6d534ba3227ea15e feat(github): add --url flag for GitHub Enterprise Server support
  • 7447ad5c122b158dbded19324553544ceae6c1c5 feat(github): detect and validate GitHub App installation tokens
  • 27641b2a1fe3d662461d4817934d5702cde05332 feat(github): direct-branch delivery in runner-on-runner for ghs_ tokens
  • 1eb385e4143f039ed5175cec579874b655a6d116 feat(github): enumerate installation repos and orgs for ghs_ tokens
  • 3860bef2fe76cd053c1bfd94e21e55c32d90751d feat(github): support installation-wide scan for ghs_ tokens
  • 593ed5496d6efb37be2a47025f8f09702827fda0 feat(scan): add --local --path for offline workflow scanning (LAB-2079)
  • 3c77e6afd51901b2f169a7d5a80736004d10b9e2 feat: add Gemini PR review workflow (Fix DNS Wildcard, Scan Hanging Bugs #28)
  • 31c0eacf96646e0db808a1f30673927566eeb30d feat: add external contribution notification workflow
  • 4a11823541b1117b26daafc110899925fe184ce0 fix(ado): check API pool data before vmImage heuristic to prevent evasion
  • 3360b9166dce342ddec1967078757c4b98c9d46b fix(ado): check ref update response for silent branch create/delete failures
  • 6446230a18b568f312df85b93317e87d4a6cdb80 fix(ado): fail closed on empty ref update response
  • f96b1eae347f6516a5aae40c48c1bede790effa9 fix(ado): use IsHosted API field for self-hosted agent pool detection
  • 133b0520e343951ba59772b09e22f4b80b0877cd fix(ci): add concurrency cancel-in-progress to Go CI/security callers (ProjectDiscovery Tools Use Hardcoded Nameservers #36)
  • d3abbd3b4ae9a19911fd43a3981731613ae8b759 fix(ci): bump Claude reusables to public-workflows v2.6.4 (opus-4-8 adaptive-thinking) (fixed wildcard detection bug, added helpful log message #55)
  • 58a5f638cf9287a901301f92132b2e26a99d207d fix(ci): bump claude-md-drift to v2.3.1 and remove invalid timeout-minutes (Improved BBOT Python API #41)
  • 517a6ea4053353b8c5eef43ad862f107dd9df988 fix(ci): declare explicit caller-side permissions for reusable
  • 99049c5399f705b0d67a43832bfc5acfbaab0130 fix(ci): drop secrets: inherit from titus caller (least-privilege) (Automate traceback debug logging #51)
  • 522f73adbaa6d7433c1719beeb56f30cb9d5080e fix(ci): grant pull-requests: read to secrets-scan (fixes startup_failure) (Excavate Hostname Extraction Is Slow With Many Scan Targets #47)
  • 3e3f99a32f548b0ca8b1e541b67c0428705f44ec fix(ci): migrate golangci.yml to v2 and resolve scanner data race
  • 6a1d6ea3d2da76de8fa1cbb4c2dc8d0efc5057d1 fix(ci): pass only the reusable's declared secrets (not inherit)
  • cad81da1725e8123bd06023372b4934661c3f0cc fix(ci): pin codex-code.yml to public-workflows v2.1.2 (Scope distance bug with new events #31)
  • 44c278d32d491dd0184639a25d78064d3850096d fix(ci): pin public-workflows @ main → v2.0.4 SHA (hardening + P0 fix)
  • c888a60c2dc510923a429d5bd4bc93c5800cfc97 fix(ci): re-pin titus-scan to real tag v2.6.0 + adopt verify-pins gate (DNS Retries #50)
  • 1df9692766a111e31140dbeffbf06dee46cc42c4 fix(claude-code): add ready_for_review to trigger types (‘pipx install bbot’ and ‘pip install bbot’ failed. Help #25)
  • f7add04f8149541a0b78161701c8965b4c83695d fix(gitlab): handle include:file list syntax and deduplicate MR trigger logic
  • 7c03dd38686e32577c8a7c690c9921c52ed107cf fix(secrets-scan): fail-closed on public repo (fail-on-findings: true) (Optimized excavate hostname extraction #48)
  • b5f25a2e1ef861b0e638173ce7cf25cf59820e9c fix: add Content-Type check to doWrite for GHES maintenance detection
  • 9a9cfe97a5f318ee42a98574a3f3b39252b357de fix: bump titus-scan SHA to include preflight permissions fix (Idiotic results from httpx #35)
  • 7c7bfa0469a920e3cb40d5d20a084d5816b19036 fix: correct mismatched vulnerability class in GitLab detections
  • 98fb1ebedfda1e42346ff7f36bd7359b6d8e5a15 fix: minor fixes and cleanups in GitLab client and attack plugins
  • dc00061f9f6a5d77d18a83174cf9f521d434b1dc fix: register missing GitLab attack plugins in global registry
  • b3ca4bd914130d23eeaa77f967317ea2b9cefca9 recalibrate: adjust non-AI detection severities across platforms
  • 60ab9eadc4a483b038d4868af83a4d9455e055b2 recalibrate: cap all AI detection severities at MEDIUM
  • 2778ab28ada12aa3d5b1b4056f1c919d0686f772 refactor(gitlab): replace string-based HTTP error checks with typed APIError
  • ef0b34fb768ca778b6f9087ea1e274607847ae81 refactor(scan): address PR Gowitness Chromium Fix + Better Tests #40 nitpicks round 3 (LAB-2079)
  • 08f453107b30973ce44f5170dc1e6b4888b62e6c refactor(scan): address PR Gowitness Chromium Fix + Better Tests #40 review feedback (LAB-2079)
  • 4fd3b7c234020f15d9c5ae005f9bef1b3ac8f7e4 refactor(scan): address PR Gowitness Chromium Fix + Better Tests #40 review feedback round 2 (LAB-2079)
  • cae7a6bb6bdafd5d086a809532f2d827f92d78b1 refactor(scan): collapse --local + --path into single --path flag (LAB-2079)
  • 166b4754f46c4971c81342ffdeffdae55cca0725 refactor(scan): dedup scanLocal/RunLocalScan via lib.Scan (LAB-2079)
  • 2af21b5f557e6be28c34f9cd9177dd73b3f7f2bc refactor: align with v2 pattern used by other repos
  • 8dd9387b2fa9ebde46954764d8c03b6eccaea085 refactor: remove dead zero-count display infrastructure
  • acb20c91dd197b44a9752ac6c7035b95d8d6e1fa refactor: use repository variables instead of hardcoded IDs
  • 11d9b8f5ea589246f80f4b769fd9a403dedf430c style(jenkins): fix goimports ordering in new TestRequiresAPI tests (LAB-2079)

@blsaccess
blsaccess requested a review from a team as a code owner November 20, 2026 00:20
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91%. Comparing base (1ead7cc) to head (21d7e87).
⚠️ Report is 4 commits behind head on dev.

Additional details and impacted files
@@          Coverage Diff          @@
##             dev   #3669   +/-   ##
=====================================
+ Coverage     91%     91%   +1%     
=====================================
  Files        465     465           
  Lines      52188   52188           
=====================================
+ Hits       47281   47293   +12     
+ Misses      4907    4895   -12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Report

Comparing dev (1ead7cc26) (baseline) vs update-trajan (1818b5f80) (current)

📈 Detailed Results (All Benchmarks)

📋 Complete results for all benchmarks - includes both significant and insignificant changes

🧪 Test Name 📏 Base 📏 Current 📈 Change 🎯 Status
Bloom Filter Dns Mutation Tracking Performance 2.21ms 2.26ms +2.2% ⚪ ✅
Bloom Filter Large Scale Dns Brute Force 9.29ms 9.39ms +1.1% ⚪ ✅
Large Closest Match Lookup 216.25ms 214.51ms -0.8% ⚪ ✅
Realistic Closest Match Workload 118.98ms 117.30ms -1.4% ⚪ ✅
Event Memory Medium Scan 1389 B/event 1389 B/event +0.0% ⚪ ✅
Event Memory Large Scan 1514 B/event 1514 B/event +0.0% ⚪ ✅
Event Validation Full Scan Startup Small Batch 21.46ms 21.08ms -1.8% ⚪ ✅
Event Validation Full Scan Startup Large Batch 110.18ms 110.11ms -0.1% ⚪ ✅
Make Event Autodetection Small 16.30ms 16.31ms +0.1% ⚪ ✅
Make Event Autodetection Large 165.52ms 164.71ms -0.5% ⚪ ✅
Make Event Explicit Types 6.98ms 6.95ms -0.3% ⚪ ✅
Excavate Single Thread Small 2.513s 2.557s +1.8% ⚪ ✅
Excavate Single Thread Large 6.619s 6.566s -0.8% ⚪ ✅
Excavate Parallel Tasks Small 2.743s 2.719s -0.9% ⚪ ✅
Excavate Parallel Tasks Large 4.401s 4.301s -2.3% ⚪ ✅
Intercept Throughput Small 353.71ms 353.58ms -0.0% ⚪ ✅
Intercept Throughput Medium 351.69ms 354.13ms +0.7% ⚪ ✅
Dns Throughput Quiet 1.252s 1.233s -1.5% ⚪ ✅
Dns Throughput Loaded 683.83ms 706.80ms +3.4% ⚪ ✅
Dns Throughput Inherited 1.028s 1.020s -0.8% ⚪ ✅
Is Ip Performance 1.36ms 1.35ms -0.8% ⚪ ✅
Make Ip Type Performance 112.73µs 112.54µs -0.2% ⚪ ✅
Mixed Ip Operations 1.42ms 1.44ms +1.3% ⚪ ✅
Memory Use Web Crawl 1.1 MB 1.1 MB -0.9% ⚪ ✅
Memory Use Subdomain Enum 27.8 MB 27.8 MB -0.0% ⚪ ✅
Memory Use Deep Chain 5.1 MB 5.1 MB +0.0% ⚪ ✅
Memory Use Parallel Chains 14.0 MB 12.2 MB -12.7% 🟢🟢 🚀
Scan Throughput 100 1.653s 1.772s +7.2% ⚪ ✅
Scan Throughput 1000 12.499s 13.125s +5.0% ⚪ ✅
Typical Queue Shuffle 3.61µs 3.58µs -0.8% ⚪ ✅
Priority Queue Shuffle 17.41µs 17.29µs -0.7% ⚪ ✅

🎯 Performance Summary

+ 1 improvement 🚀
  30 unchanged ✅

🔍 Significant Changes (>10%)

  • Memory Use Parallel Chains: 12.7% 🚀 less memory

🐍 Python Version 3.12.3

@singlerider singlerider added the enhancement New feature or request label Nov 20, 2026

@en0f en0f 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.

Reviewed at 21d7e87.

Reproduce this review
# save the script below as verify-3669.sh, then:
bash verify-3669.sh blacklanternsecurity/bbot 21d7e87236b185e1ff1b579af8a605dd2fc8b7d6
# expected: SUMMARY 9 PASS, 2 FAIL, 0 SKIP, 0 BROKEN (V09 and V11 are pre-existing, outside this bump)
# control:  bash verify-3669.sh blacklanternsecurity/bbot 1ead7cc262c7608aaf123d7f6fbbf6b671aa8005   -> V01=FAIL
#!/usr/bin/env bash
# verify-3669.sh: reproducible checks for blacklanternsecurity/bbot#3669 (trajan 1.0.0 -> 1.0.2)
# Usage: bash verify-3669.sh <owner/repo> <sha> [<control-patch>]
# Changes nothing outside a mktemp directory and nothing on GitHub (PR-VF-02).
# The trajan binary is downloaded and checksummed, never executed.
#
# CONTROL: sha 1ead7cc262c7608aaf123d7f6fbbf6b671aa8005
# CONTROL-EXPECT: V01=FAIL
# AUTHOR-CODE: none
set -uo pipefail

REPO="${1:?owner/repo}"; SHA="${2:?sha}"; PATCH="${3:-}"
PASS=0; FAIL=0; SKIP=0; BROKEN=0
pass()   { echo "PASS $1 $2"; PASS=$((PASS+1)); }
fail()   { echo "FAIL $1 $2 -- $3"; FAIL=$((FAIL+1)); }
skip()   { echo "SKIP $1 $2 -- $3"; SKIP=$((SKIP+1)); }
broken() { echo "BROKEN $1 $2 -- $3"; BROKEN=$((BROKEN+1)); }
summary() { echo "SUMMARY $PASS PASS, $FAIL FAIL, $SKIP SKIP, $BROKEN BROKEN"; [ "$FAIL" -eq 0 ] && [ "$BROKEN" -eq 0 ]; }

echo "script_sha256 $(shasum -a 256 "$0" | cut -d' ' -f1)"
echo "git $(git --version | cut -d' ' -f3)"
echo "curl $(curl --version | head -1 | cut -d' ' -f2)"
echo "python3 $(python3 -c 'import platform; print(platform.python_version())')"
echo "gh $(gh --version | head -1 | cut -d' ' -f3)"

WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_TERMINAL_PROMPT=0
GIT=(git -c credential.helper= -c 'credential.helper=!gh auth git-credential')
"${GIT[@]}" clone --quiet --filter=blob:none --no-checkout "https://github.com/$REPO.git" "$WORK/src" || { broken V00 "clone" "clone failed"; summary; exit 1; }
cd "$WORK/src"
"${GIT[@]}" cat-file -e "$SHA^{commit}" 2>/dev/null || "${GIT[@]}" fetch --quiet origin "+refs/pull/*/head:refs/remotes/pr/*" || true
"${GIT[@]}" checkout --quiet --detach "$SHA" || { broken V00 "checkout $SHA" "checkout failed"; summary; exit 1; }
[ "$(git rev-parse HEAD)" = "$SHA" ] || { broken V00 "HEAD is $SHA" "HEAD mismatch"; summary; exit 1; }
if [ -n "$PATCH" ]; then git apply "$PATCH" || { broken V00 "apply control patch" "git apply failed"; summary; exit 1; }; fi

MOD=bbot/modules/trajan.py
VER="$(python3 -I -c 'import re,sys; m=re.search(r"version: VersionStr = Field\(\"([0-9.]+)\"", open(sys.argv[1]).read()); print(m.group(1) if m else "")' "$MOD")"
[ -n "$VER" ] || { broken V00 "read pinned trajan version" "no version Field in $MOD"; summary; exit 1; }
echo "pinned_trajan $VER"
UP=praetorian-inc/trajan
gh api --method GET "repos/$UP/releases/latest" > "$WORK/latest.json" 2>/dev/null || { broken V00 "read trajan releases/latest" "gh api failed"; summary; exit 1; }
gh api --method GET "repos/$UP/releases/tags/v$VER" > "$WORK/rel.json" 2>/dev/null || echo '{}' > "$WORK/rel.json"
LATEST="$(python3 -I -c 'import json,sys; print(json.load(open(sys.argv[1]))["tag_name"].lstrip("v"))' "$WORK/latest.json")"
echo "latest_trajan $LATEST"

# ---- checks: each line states the desired property --------------------------

# V01: the module pins the newest stable trajan release
if [ "$VER" = "$LATEST" ]; then pass V01 "trajan.py pins the latest stable trajan release ($LATEST)"
else fail V01 "trajan.py pins the latest stable trajan release ($LATEST)" "pinned $VER"; fi

# V02: every asset bbot's deps_ansible URL resolves to exists for the pinned version
# URL template: trajan_#{VERSION}_#{BBOT_OS}_#{BBOT_CPU_ARCH_GOLANG}.tar.gz
MISSING="$(python3 -I -c '
import json,sys
names={a["name"] for a in json.load(open(sys.argv[1])).get("assets",[])}
v=sys.argv[2]
want=[f"trajan_{v}_{o}_{a}.tar.gz" for o in ("linux","darwin") for a in ("amd64","arm64")]
print(" ".join(w for w in want if w not in names))' "$WORK/rel.json" "$VER")"
if [ -z "$MISSING" ]; then pass V02 "v$VER publishes the tar.gz for linux/darwin x amd64/arm64 that deps_ansible downloads"
else fail V02 "v$VER publishes the tar.gz for linux/darwin x amd64/arm64 that deps_ansible downloads" "missing: $MISSING"; fi

# V09: the URL deps_ansible builds on macOS resolves to a published asset.
# bbot sets BBOT_OS from os_platform_friendly(), which returns "macOS" on darwin;
# BBOT_OS_PLATFORM is the raw "darwin". Pre-existing (same template at the base).
OSF="$(python3 -I -c '
import re,sys
s=open(sys.argv[1]).read()
m=re.search(r"def os_platform_friendly\(\):.*?if p == \"darwin\":\s*return \"(\w+)\"", s, re.S)
print(m.group(1) if m else "darwin")' bbot/core/helpers/misc.py)"
OSVAR="$(grep -oE '#\{BBOT_OS(_PLATFORM)?\}_#\{BBOT_CPU_ARCH_GOLANG\}' "$MOD" | head -1)"
case "$OSVAR" in *BBOT_OS_PLATFORM*) MACOS=darwin;; *) MACOS="$OSF";; esac
MACASSET="trajan_${VER}_${MACOS}_arm64.tar.gz"
if python3 -I -c 'import json,sys; sys.exit(0 if any(a["name"]==sys.argv[2] for a in json.load(open(sys.argv[1])).get("assets",[])) else 1)' "$WORK/rel.json" "$MACASSET"; then
  pass V09 "on macOS, deps_ansible resolves to a published asset ($MACASSET)"
else fail V09 "on macOS, deps_ansible resolves to a published asset" "template uses $OSVAR -> $MACASSET, not published (asset is darwin)"; fi

# V03/V04: the linux_amd64 tarball matches the vendor checksum (and the API digest) and holds a root-level 'trajan' member
ASSET="trajan_${VER}_linux_amd64.tar.gz"
BASEURL="https://github.com/$UP/releases/download/v$VER"
if curl -fsSLo "$WORK/$ASSET" "$BASEURL/$ASSET" && curl -fsSLo "$WORK/checksums.txt" "$BASEURL/checksums.txt"; then
  SUM="$(awk -v f="$ASSET" '$2==f{print $1}' "$WORK/checksums.txt")"
  APIDIG="$(python3 -I -c 'import json,sys; print(next((a.get("digest") or "" for a in json.load(open(sys.argv[1]))["assets"] if a["name"]==sys.argv[2]),"").removeprefix("sha256:"))' "$WORK/rel.json" "$ASSET")"
  GOT="$(shasum -a 256 "$WORK/$ASSET" | cut -d' ' -f1)"
  if [ -n "$SUM" ] && [ "$GOT" = "$SUM" ] && { [ -z "$APIDIG" ] || [ "$GOT" = "$APIDIG" ]; } \
     && tar tzf "$WORK/$ASSET" > "$WORK/members.txt" && grep -qx 'trajan' "$WORK/members.txt"; then
    pass V03 "$ASSET matches checksums.txt and the release API digest, and contains the 'trajan' member deps_ansible extracts"
  else
    fail V03 "$ASSET matches checksums.txt and the release API digest, and contains the 'trajan' member deps_ansible extracts" "got=$GOT checksums=$SUM api=$APIDIG"
  fi
  if echo "0000000000000000000000000000000000000000000000000000000000000000  $WORK/$ASSET" | shasum -a 256 -c - >/dev/null 2>&1; then
    broken V04 "wrong-hash control is rejected" "accepted a wrong hash"
  else pass V04 "wrong-hash control is rejected"; fi
else
  skip V03 "$ASSET matches checksums.txt and contains 'trajan'" "download failed"
  skip V04 "wrong-hash control is rejected" "download failed"
fi

# Upstream source at the pinned tag (read, never built or run)
"${GIT[@]}" clone --quiet --filter=blob:none --no-checkout "https://github.com/$UP.git" "$WORK/trajan" \
  && git -C "$WORK/trajan" rev-parse -q --verify "refs/tags/v$VER^{commit}" >/dev/null \
  && echo "trajan_tag v$VER $(git -C "$WORK/trajan" rev-parse "v$VER^{commit}")" \
  || { broken V05 "clone trajan at v$VER" "clone or tag failed"; summary; exit 1; }
show() { git -C "$WORK/trajan" show "v$VER:$1" 2>/dev/null; }
flags() { for f in "$@"; do show "$f"; done | grep -E 'Flags\(\)\.' | grep -oE '(\(&[A-Za-z.]+, |String\()"[a-z-]+"' | grep -oE '"[a-z-]+"' | tr -d '"' | sort -u; }

# V05: every flag execute_trajan passes exists on that subcommand at v$VER
ROOTF="$(flags cmd/trajan/root.go)"
MISS=""
need() { local sub="$1"; shift; local have; have="$(printf '%s\n%s\n' "$ROOTF" "$(flags cmd/trajan/$sub/scan.go cmd/trajan/$sub/root.go)")"
  for fl in "$@"; do printf '%s\n' "$have" | grep -x "$fl" >/dev/null || MISS="$MISS $sub:--$fl"; done; }
need github  repo output token
need gitlab  project output token
need ado     org repo output token
need jfrog   url secrets output token
need jenkins url repo output token username password
if [ -z "$MISS" ]; then pass V05 "trajan v$VER defines every flag trajan.py passes to github/gitlab/ado/jfrog/jenkins scan"
else fail V05 "trajan v$VER defines every flag trajan.py passes to github/gitlab/ado/jfrog/jenkins scan" "missing:$MISS"; fi

# V10: trajan.py passes the -o shorthand, so the root command must still define it for --output (challenge C6)
if show cmd/trajan/root.go | grep -E 'PersistentFlags\(\)\.StringVarP\(&output, "output", "o"' >/dev/null; then
  pass V10 "trajan v$VER root command defines -o as the shorthand for --output"
else fail V10 "trajan v$VER root command defines -o as the shorthand for --output" "not found in cmd/trajan/root.go"; fi

# V11: the deps installer's setup_status key changes when the trajan version changes (challenge C8).
# _module_hash() hashes the preloaded deps (the deps_ansible literal, placeholder unsubstituted) plus bbot __version__.
# Pre-existing: compares this tree's literal with its first parent's.
DEPSCMP="$(python3 -I -c '
import ast,json,subprocess,sys
def d(s):
    for n in ast.walk(ast.parse(s)):
        if isinstance(n,ast.Assign) and any(getattr(t,"id",None)=="deps_ansible" for t in n.targets):
            return json.dumps(ast.literal_eval(n.value),sort_keys=True)
cur=open("bbot/modules/trajan.py").read()
try: par=subprocess.check_output(["git","show","HEAD~1:bbot/modules/trajan.py"],stderr=subprocess.DEVNULL).decode()
except Exception: print("NOPARENT"); sys.exit()
print("SAME" if d(cur)==d(par) else "DIFF")')"
case "$DEPSCMP" in
  DIFF) pass V11 "the trajan version change alters the deps setup_status hash input";;
  SAME) fail V11 "the trajan version change alters the deps setup_status hash input" "deps_ansible literal identical to HEAD~1; installs at the same bbot version keep the old binary";;
  *) skip V11 "the trajan version change alters the deps setup_status hash input" "no parent commit";;
esac

# V06: the JSON keys parse_findings / parse_jfrog_results read are still emitted at v$VER
# (grep a file, not a pipe: grep -q exiting early SIGPIPEs printf, and pipefail turns that into a false miss)
{ show internal/cmdutil/scan.go; show pkg/detections/finding.go; show cmd/trajan/jfrog/scan.go; show pkg/jfrog/artifacts.go; show pkg/jfrog/types.go; } > "$WORK/jsonsrc.go"
MISSK=""
for k in findings type severity evidence workflow artifactSecrets buildSecrets secretTypes artifact path buildName buildNumber envVar; do
  grep -qE "json:\"$k[,\"]" "$WORK/jsonsrc.go" || MISSK="$MISSK $k"; done
if [ -z "$MISSK" ]; then pass V06 "trajan v$VER JSON output still carries every key trajan.py parses"
else fail V06 "trajan v$VER JSON output still carries every key trajan.py parses" "missing:$MISSK"; fi

# V07: every trajan severity, upper-cased, is a severity bbot's FINDING accepts
BAD="$(python3 -I -c '
import re,sys
trajan=set(re.findall(r"Severity\w* +Severity = \"(\w+)\"", sys.stdin.read()))
src=open(sys.argv[1]).read()
m=re.search(r"_severity_order = \[([^\]]*)\]", src)
bbot=set(re.findall(r"\"(\w+)\"", m.group(1))) if m else set()
print("NOBBOT" if not bbot else ("NOTRAJAN" if not trajan else " ".join(sorted(s for s in trajan if s.upper() not in bbot))))' bbot/core/event/base.py < <(show pkg/detections/finding.go))"
case "$BAD" in
  NOBBOT|NOTRAJAN) broken V07 "trajan severities map onto bbot severities" "could not parse ($BAD)";;
  "") pass V07 "every trajan v$VER severity, upper-cased, is a bbot FINDING severity";;
  *) fail V07 "every trajan v$VER severity, upper-cased, is a bbot FINDING severity" "unmapped: $BAD";;
esac

# V08: the module's own test ran green in CI at this SHA
if [ -f bbot/test/test_step_2/module_tests/test_module_trajan.py ]; then
  CR="$(gh api --method GET "repos/$REPO/commits/$SHA/check-runs" --paginate -q '.check_runs[] | select(.name|test("^test / test \\(")) | .conclusion' 2>/dev/null | sort -u | tr '\n' ' ')"
  if [ -z "$CR" ]; then skip V08 "test_module_trajan ran green in CI (test / test matrix) at $SHA" "no test matrix check runs at this SHA"
  elif [ "$CR" = "success " ]; then pass V08 "test_module_trajan ran green in CI (test / test matrix) at $SHA"
  else fail V08 "test_module_trajan ran green in CI (test / test matrix) at $SHA" "conclusions: $CR"; fi
else fail V08 "test_module_trajan exists" "missing"; fi
# ------------------------------------------------------------------------------
summary

@liquidsec
liquidsec merged commit c339f34 into dev Nov 20, 2026
27 checks passed
@liquidsec
liquidsec deleted the update-trajan branch November 20, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants