Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions developers/attack-surface-source-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: Write an attack-surface source adapter
parent: Developers
nav_order: 11
---
{% raw %}

# Write an attack-surface source adapter

An edge sensor watches your internet-facing assets from outside your network and brings the
results in. What it observes comes from a **source adapter**. The sensor's own discovery tools
are one adapter. You can write another, for example one that reads an attack-surface product
you already pay for, and the platform treats its results exactly like the built-in ones.

The platform never knows which adapter produced a record. It receives sealed pages of
[CTIS](https://github.com/openctemio/ctis) reports, each page labelled with the adapter's id.
You write no platform code and no console code.

## What an adapter is

An adapter is a Go type that implements `edgesync.Source` from
[sdk-go](https://github.com/openctemio/sdk-go) (`pkg/edgesync`):

```go
type Source interface {
// Describe returns the manifest.
Describe() Manifest
// Pull returns observations after cursor (nil: from the start) and the
// cursor to continue from.
Pull(ctx context.Context, run Run, cursor []byte) (Batch, []byte, error)
}
```

- `Describe` returns a **manifest**:
- `ID`: a lower-case id such as `acme.asm`;
- `Name`, `Version`;
- `Emits`: the asset types you report (`domain_name`, `ip_address`, `service`, `web_origin`,
`certificate`) and `finding`;
- `Capabilities`: what your adapter does, one kind of act each, at major version 1 (for example
`discover.subdomains@1`);
- `ConfigSchema`: a JSON Schema of your settings. The console renders it as a form. Mark
secrets `"writeOnly": true`; their values are read on the host that runs the adapter, never
sent to the platform;
- `RateLimit`: how fast you call the systems you read;
- `Label`: the provenance label shown on every record ("Acme ASM").
- `Pull` gets a `Run` and your last cursor:
- `Run.Scope` is the public scope the organization signed: roots, ranges, exclusions and the
entries allowed active checks;
- `Run.Active` is false when active checks are not allowed now;
- `Run.Snapshot` asks for the full picture instead of changes.

It returns a `Batch` of CTIS reports, items you stopped seeing (`Gone`, which the platform
reads as "not seen", never as "fixed"), and your next cursor (at most 64 KiB).

## The rules your adapter must follow

1. **Work only inside the scope.** Ask only about names under `Scope.Roots` and addresses in
`Scope.Ranges`, never anything in `Scope.Exclusions`. Run an active check only where
`Scope.ActiveAllowed` says yes.
2. **Report nothing internal.** The edge filters every report anyway (`edgesync.FilterReport`):
internal addresses (RFC 1918, loopback, link-local, unique local and the rest), internal names
(`.local`, `.internal`, `.corp`, single labels…), names outside the scope and asset types that
are not visible from the internet are dropped and counted. The conformance kit fails an
adapter that emits any of them.
3. **Use the mapping helpers for identity.** `edgesync.DomainAsset`, `AddressAsset`,
`ServiceAsset`, `OriginAsset` and `CertificateAsset` give every asset its canonical value and
reference, so the same host seen by your adapter, the built-in tools and an internal scan
becomes one asset and one finding. `edgesync.Severity`, `CVE` and `CWE` normalize the rest.
4. **Keep credentials on the host.** Your adapter runs on the edge host, or on the relay host
inside your network when the product you read is itself a service on the internet. Read API
keys from files there. Nothing you hold is sent to the platform.
5. **Your data is evidence.** The platform never widens scope, authorizes a scan, overrides a
person's decision or closes another source's finding because of an adapter's record.

## A minimal adapter

The SDK ships a skeleton in
[`pkg/edgesync/example`](https://github.com/openctemio/sdk-go/tree/main/pkg/edgesync/example).
Its core:

```go
func (s *Source) Pull(_ context.Context, run edgesync.Run, _ []byte) (edgesync.Batch, []byte, error) {
r := ctis.NewReport()
r.Metadata.Channel = ctis.ChannelCollector
r.Tool = &ctis.Tool{Name: "acme-asm", Version: "1.0.0"}
for _, rec := range s.records() { // your API call
if !run.Scope.InScope(rec.Host) {
continue
}
host, err := edgesync.DomainAsset(rec.Host)
if err != nil {
continue
}
r.Assets = append(r.Assets, host)
if rec.Issue != "" {
r.Findings = append(r.Findings, ctis.Finding{
Type: ctis.FindingTypeMisconfiguration, Title: rec.Issue,
Severity: edgesync.Severity(rec.Severity), AssetRef: host.ID,
})
}
}
return edgesync.Batch{Reports: []*ctis.Report{r}, Complete: true}, s.nextCursor(), nil
}
```

## Prove it with the conformance kit

Every adapter must pass `pkg/edgesync/conformance`:

```go
func TestConformance(t *testing.T) {
conformance.Run(t, acme.New(testConfig), conformance.Options{})
}
```

It checks:

- the manifest;
- valid CTIS;
- only the declared types;
- nothing internal and nothing outside the scope;
- references from the mapping helpers;
- the same assets on two pulls from the start;
- `Gone` entries;
- the cursor resumes;
- a passive run works.

The default scope uses the documentation names and ranges (`example.com`, `example.net`,
`192.0.2.0/24`, `198.51.100.0/24`, `203.0.113.0/24`, `2001:db8::/32`). Feed your adapter
recorded answers from those, never real customer data.

## Ship it

Ship an adapter as its own container image or binary, signed with cosign, the same way the
[Tenable.sc connector](../sensors/connector-tenable.md) ships. The kit verifies the signature
before it runs anything. An organization enables an adapter per link in the console.

{% endraw %}
2 changes: 2 additions & 0 deletions operations/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Which sensor, SDK, CI runner and chart releases go with the current platform rel
| From | To | Guide |
|---|---|---|
| CTIS 1.x | CTIS 2.0 | [Migrating to CTIS 2.0](ctis-2-migration.md): platform, sensors, `openctem-ci`, the Tenable connector and the asset collector are upgraded together; data migrates on start; rollback restores the pre-upgrade backup. |
| v0.30.2 | v0.31.0 | Eight additive migrations, which the `migrate` service applies before the API starts: `20261202045211_ci_runs_coverage_gaps` (a column with a constant default, no rewrite), `20261202075851_finding_link_dast_same_check` and `20261202075852_finding_link_dast_same_check_validate` (a widened check, then validated), `20261202083454_asset_technologies_software_links` and `20261202083455_asset_technologies_software_backfill` (marks gone the software whose technology a scan already removed and links stored technologies to their software), `20261204105130_repository_branch_default_source` (a nullable column, no backfill), and `20261205040207_edge_links` and `20261205040208_edge_links_validate` (the tables of [external scanning](/sensors/external-scanning/) and two columns on source records). No configuration change: update the images and nothing else. Before you upgrade, read the behaviour changes. A CI run closes what it proved fixed, so a run that is not a verified push of the default or a protected branch, or whose reports were not all full scans, closes nothing, and an unbound (warn mode) sensor report marks no branch fixed. A GitLab merge request pipeline is never a run of the default branch: if merge request pipelines from a branch named like the default branch ran before the upgrade, review the repository's findings closed by CI and its baseline under CI/CD. A scan export masks credential-looking `scanner_config` values. Two templates that test the same thing show as one issue: findings stored before link on their next scan, or at once with `refingerprint -links` (dry run first, then `-apply`). Edge mode needs sensor v0.43.0 or later; the sensor installed with v0.31.0 is v0.42.1. Every change: [v0.31.0](/operations/releases/v0-31-0/). |
| v0.30.1 | v0.30.2 | A patch release for the dashboard: its change queue no longer sticks on one batch (the log repeated `canceling statement due to user request` and the dashboard numbers stopped updating). One additive migration, `20261204065828_dashboard_dirty_queue_unstick` (one new empty table and function replacements, no data change). No configuration change: update the images and nothing else. A queue that was stuck drains on the first ticks after the upgrade. Every change: [v0.30.2](/operations/releases/v0-30-2/). |
| v0.30.0 | v0.30.1 | A security hotfix: no migration and no configuration change; update the images and nothing else, and you can roll back to v0.30.0. Behaviour changes: the threat intel API (`/api/v1/threat-intel/*`, except `/freshness`) needs an active membership and the Threat Intel module (with the module off it answers that the module is not enabled); views that list findings next to another object (IOC matches, an asset's risk explanation, affected assets, asset groups, attack paths, detections) show only the findings the member may see in the findings list; a sensor request started with an enrollment token is approved only while the token is still valid. Every change: [v0.30.1](/operations/releases/v0-30-1/). |
| v0.29.0 | v0.30.0 | Three additive migrations, which the `migrate` service applies before the API starts: `20261130095346` (the asset merge log records the private programs involved), `20261202024619_decision_review_proof_reasons` and `20261202024620_decision_review_proof_reasons_validate` (the review reason check is widened, then validated: no data change) and `20261202033604_finding_decision_seen_counter` (two counter columns on findings, filled from the next scan, and a trigger that resets the count when a decision changes). No configuration change: update the images and nothing else. Before you upgrade, read the three behaviour changes: a CI job started by a comment needs **Admit fork pull requests** on its trust configuration, proof reopens a finding marked not a real issue even when two people approved it, and `POST /api/v1/commands` with type `scan` answers 409 while scan approval is On or Strict. A restore with `backup.sh` needs free disk space for a second copy of the database ([Backup and restore](/operations/backup-restore/)). Every change: [v0.30.0](/operations/releases/v0-30-0/). |
| v0.28.0 | v0.29.0 | Five additive migrations, which the `migrate` service applies before the API starts: `20261130015036_approval_signoffs_keep_after_erasure` (the sign-off key clears the person instead of deleting the sign-off: no row is rewritten), `20261130015636_suppression_rules_soft_delete` (nullable `deleted_at` and `deleted_by` and the `deleted` status), `20261130025903_organization_purging_status` (the `purging` organization status), `20261130070726_finding_flow_location_context` (the code around a data flow step) and `20261130092933_trust_request_answers` (`tenant_trusts.home_domain` and a request log). Update the images and nothing else. Rolling back the suppression migration removes the rules marked deleted. Run `openctem-ci` v0.5.1 only against v0.29.0 or later ([CI upgrade](/scanning/ci-reference/#upgrade-from-v040-to-v050)). Every change: [v0.29.0](/operations/releases/v0-29-0/). |
Expand Down
6 changes: 5 additions & 1 deletion overview/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ The subgraphs are the trust boundaries. The platform runs in the operator's
network and accepts connections only through the gateway. The platform console
has its own site on the gateway (a port, by default 8443, or its own host
name), open only to the networks the operator allows. Sensors run in the
networks they scan and only connect out. CI jobs run at the CI provider and
networks they scan and only connect out. An edge sensor, on an internet host
outside your network, never connects to the platform at all: it leaves sealed
results in a mailbox, and a sensor inside your network brings them in. CI jobs run at the CI provider and
prove who they are with the provider's OIDC token. The platform never opens a
connection to a sensor or a CI job, and never sends probes to targets itself.

Expand Down Expand Up @@ -147,6 +149,7 @@ Details: [scan-lifecycle.md](https://github.com/openctemio/openctem/blob/develop
| Imports | Files from other scanners (Nessus, Qualys, SARIF, trivy, nuclei, ZAP and others) uploaded in the console or the API. |
| Connectors and integrations | SCM repositories (GitHub, GitLab), Tenable.sc, DefectDojo, Entra ID identity exposures, SIEM. |
| Discovery jobs | Certificate Transparency logs and DNS checks of each organization's own domains, and the automatic coverage loop that plans the checks each asset type needs, run by the API. |
| Edge sensors | An [edge sensor](../sensors/external-scanning/index.md) checks the public scope from outside your network and writes signed, encrypted pages to a mailbox (a bucket, an outbox on the edge host, or a carried folder). A sensor of the organization inside the network carries them to the platform in signed jobs; the platform checks the edge's signature, opens the pages and ingests them as evidence that never widens scope or closes another source's finding. Only the public scope goes the other way. |
| Threat intelligence | Vulnerability bundles, EPSS scores and the CISA KEV catalog, refreshed on a schedule (bundles every 20 minutes, KEV hourly, EPSS daily) and used in prioritization. The platform fetches them directly, through an HTTPS proxy, from a bundle directory, or, in relay mode, receives them from one to three platform sensors, so that it makes no outbound request for feeds ([Feeds](../operations/feeds.md)). In every mode it verifies each file against a pinned root key before it imports it. |

### Outputs
Expand Down Expand Up @@ -267,6 +270,7 @@ flowchart LR
| Automation to API | `oct_` API keys are bound to one organization and are read-only on the REST API; SCIM and CI use their own credentials. AI assistants connect to the MCP server with OAuth, as the person who approved them, within the organization's AI policy. |
| Sensor to platform | Each sensor has its own key, bound to one organization (a shared sensor to the instance); results are treated as hostile input (validated, size-capped, bound to the key's organization, quarantined when they do not match the task). |
| Platform to sensor | A sensor runs only the tools it has, can enforce a local policy set by the network owner (allowed targets, ports, tools, kill switch) whatever the platform sends, and accepts custom scanner templates only when signed. |
| Edge host to platform | No connection: the edge sensor's pages go through a mailbox that sees only ciphertext, signed with the edge key pinned at pairing (a person compares a 12-digit check) and encrypted to the platform. The relay sensor holds no key that opens them. A compromised edge exposes only the public scope and public results it already had. |
| Platform to outside services | Outbound URLs and SMTP hosts are checked against private, loopback and metadata addresses before connecting. |

Security model and hardening: [Security](../security/index.md). Engineering
Expand Down
12 changes: 12 additions & 0 deletions scanning/ci-blocked-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ failed, and what to do next.
blocking.
- **Details** on the check opens the run in the console.

The comment never notifies anybody: scanner text is escaped, so a finding
title with an at sign (`@all`) mentions nobody, and `%`, `$` and `:` cannot
start a milestone, snippet, math or emoji reference or a scheme link
(platform v0.31.0 and later). A pull request that is closed, merged or locked
gets no comment (the check or commit status is still set, and the run says why
the comment was skipped). When the code host refuses the status, check or
note, the run's feedback state says what to change: an expired or revoked
GitLab token, the `api` scope and Developer role a GitLab group access token
needs, a project outside the connected group, or the GitHub App permissions
(Checks and Pull requests: write). Rate limits and server errors are retried
with backoff.

## Read the run

The run sheet shows the verdict, the policy that applied, how many findings
Expand Down
Loading
Loading