Skip to content

feat(tencent/security): expose 10 scans as cobra subcommands#181

Merged
rafeegnash merged 1 commit into
masterfrom
feat/tencent-security-subcommands
May 28, 2026
Merged

feat(tencent/security): expose 10 scans as cobra subcommands#181
rafeegnash merged 1 commit into
masterfrom
feat/tencent-security-subcommands

Conversation

@rafeegnash
Copy link
Copy Markdown
Collaborator

Summary

Adds clanker tencent security <scan> for the ten Tencent Cloud security scans that previously lived only on the in-process HTTP server (clanker server). The downstream clanker-cloud Security panel needs them as shell-out targets, matching the inventory / cost / expiry pattern.

Each scan registers through a small securityScan struct so adding a new one is one append, not three. The fan-out clanker tencent security all runs every scan in parallel and emits a wrapped envelope — per-scan failures are surfaced inside the envelope rather than aborting the bundle, so a single IAM gap doesn't black out the other nine scans.

Surface

clanker tencent security public-exposure --region ap-singapore
clanker tencent security clb-exposure --region ap-singapore
clanker tencent security db-exposure --region ap-singapore
clanker tencent security idle-eips --region ap-singapore
clanker tencent security unencrypted-cbs --region ap-singapore
clanker tencent security cert-expiry --days 30
clanker tencent security cam-hygiene
clanker tencent security waf-coverage
clanker tencent security antiddos-coverage --region ap-singapore
clanker tencent security audit-coverage
clanker tencent security all  # wrapped envelope across all 10

All scans emit raw JSON on stdout — same shape the HTTP server already returns, so jq pipelines and the dashboard share a wire format.

Output of security all

{
  "region": "ap-singapore",
  "scans": [
    {"name":"public-exposure","data":{...}},
    {"name":"cam-hygiene","error":"permission denied: cam:DescribeSubAccount"}
  ]
}

Test plan

  • go test -race -count=1 ./internal/tencent/... -run Security — 3/3 pass
  • go test -race -count=1 -short ./... — full suite green
  • go vet ./... — clean
  • gofmt -s -l — clean
  • Manual: clanker tencent security --help lists 11 subcommands (10 scans + all)

The ten Tencent security scans (public-exposure, clb-exposure,
db-exposure, idle-eips, unencrypted-cbs, cert-expiry, cam-hygiene,
waf-coverage, antiddos-coverage, audit-coverage) were already
exposed through the clanker server HTTP API, but not as cobra
subcommands. Downstream clanker-cloud needs them as shell-out
targets so the dashboard's Security panel can run them without
standing up an in-process HTTP server.

Each scan registers via a small securityScan struct so adding a
new one means appending one entry to securityScans rather than
plumbing through every layer. The 'all' fan-out command runs
every scan in parallel and emits a wrapped envelope:

  {"region":"ap-singapore","scans":[
    {"name":"public-exposure","data":{...}},
    {"name":"cam-hygiene","error":"permission denied"}
  ]}

Per-scan failures are captured in the envelope rather than
aborting the whole call so a single IAM gap doesn't black out
the other nine scans.

Tests cover the registry invariants, the cobra subtree wiring,
and the fan-out's error-capture behaviour (race-clean by passing
the scan list into runAllSecurityScans rather than mutating the
package global).
@rafeegnash rafeegnash merged commit 1413fc9 into master May 28, 2026
5 checks passed
@rafeegnash rafeegnash deleted the feat/tencent-security-subcommands branch May 28, 2026 06:58
rephapeng added a commit to rephapeng/clanker that referenced this pull request May 28, 2026
Upstream merged PR bgdnvk#165 (Tencent provider) and added work on top:
k8s SRE playbooks (bgdnvk#174), SRE agent fix (bgdnvk#177), tree-wide gofmt -s
(bgdnvk#176), README (bgdnvk#175), and three Tencent CLI features the fork lacked
— `list --format json` (bgdnvk#179), `cost --format json` (bgdnvk#180), and
security-scan CLI subcommands (bgdnvk#181).

Conflict resolution: all 16 conflicts resolved to upstream's side.
14 were pure gofmt whitespace from bgdnvk#176 (identical code); billing.go
and static_commands.go were upstream supersets adding the JSON/security
CLI surface with no fork-unique code lost. Fixed a duplicate tencent
import in cmd/ask.go left by the auto-merge.

Verified in Docker (golang:1.25, -mod=mod): gofmt clean, go build ./...,
go vet ./..., and go test ./... all pass.
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.

1 participant