feat(ci): PLC fixtures for the nightly scan regression (#314) #324
No files matched your search
@@ -1,9 +1,10 @@
|
||||
name: Nightly scan regression
|
||||
|
||||
# Scans the fixture corpus (fixtures/demo-targets) with the agent image built
|
||||
# from main and compares the results with the blessed baselines in
|
||||
# fixtures/nightly/baselines (#188, epic #309). A regression anywhere between
|
||||
# a tool bump and a parser change turns this red before a customer sees it.
|
||||
# Scans the fixture corpus (fixtures/demo-targets and fixtures/nightly) with
|
||||
# the agent image built from main and compares the results with the blessed
|
||||
# baselines in fixtures/nightly/baselines (#188, epic #309). A regression
|
||||
# anywhere between a tool bump and a parser change turns this red before a
|
||||
# customer sees it.
|
||||
#
|
||||
# Run it by hand with "bless" ticked after an intended change: the job then
|
||||
# rewrites the baselines instead of comparing, and the new files are in the
|
||||
@@ -66,6 +67,9 @@ jobs:
|
||||
# which the report lists as advisory; it never fails the run.
|
||||
LITELLM_URL: ${{ secrets.NIGHTLY_LITELLM_URL }}
|
||||
LITELLM_API_KEY: ${{ secrets.NIGHTLY_LITELLM_API_KEY }}
|
||||
# Optional. The CODESYS CVE match queries NVD, which rate-limits
|
||||
# unauthenticated clients; a key keeps those CVEs from going missing.
|
||||
NVD_API_KEY: ${{ secrets.NIGHTLY_NVD_API_KEY }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
@@ -105,6 +109,18 @@ jobs:
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
# The real CODESYS sample is ~10 MB, so it is fetched at a pinned commit
|
||||
# and checksum rather than committed. fixtures/nightly/targets.json skips
|
||||
# its target where NIGHTLY_CODESYS_SAMPLE is unset.
|
||||
- name: Fetch the CODESYS sample
|
||||
run: |
|
||||
curl -fsSL -o /tmp/csv-blackbox.projectarchive \
|
||||
"https://github.com/Proemion/codesys-examples/raw/164d8eea7b7483f764b4959788fd2a733624e576/CSV-BlackBox-Writter/CSV-BlackBox-Writter.projectarchive"
|
||||
echo "8e1150728e33fc0f5e2572bc060545497cfa64308c927c0d81ecda71873db265 /tmp/csv-blackbox.projectarchive" \
|
||||
| sha256sum -c -
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
- name: Wait for the agent
|
||||
run: |
|
||||
for i in $(seq 1 90); do
|
||||
@@ -120,8 +136,18 @@ jobs:
|
||||
run: cargo test -p compliance-agent --test nightly -- --nocapture
|
||||
env:
|
||||
NIGHTLY_AGENT_URL: http://agent:3001
|
||||
NIGHTLY_CODESYS_SAMPLE: /tmp/csv-blackbox.projectarchive
|
||||
NIGHTLY_BLESS: ${{ inputs.bless && '1' || '0' }}
|
||||
|
||||
# upload-artifact is a Node action and the Rust image has no node.
|
||||
- name: Install node for the artifact upload
|
||||
if: always()
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends nodejs >/dev/null
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
- name: Keep the report and this run's snapshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -148,11 +148,16 @@ This starts MongoDB, SearXNG, the agent (port 3001), and the dashboard (port 808
|
||||
|
||||
### Nightly scan regression
|
||||
|
||||
Every night CI scans the demo-target corpus (`fixtures/demo-targets/targets.json`)
|
||||
with the agent image built from `main` and compares the results with the
|
||||
baselines in `fixtures/nightly/baselines/` (`.gitea/workflows/nightly.yml`). To
|
||||
run it against any agent in dev mode (use a fresh database: a rescan of an
|
||||
unchanged repo skips most stages, so it records less than a first scan):
|
||||
Every night CI scans the fixture corpus with the agent image built from `main`
|
||||
and compares the results with the baselines in `fixtures/nightly/baselines/`
|
||||
(`.gitea/workflows/nightly.yml`). The corpus is the demo targets
|
||||
(`fixtures/demo-targets/targets.json`, seeded by the agent itself) plus the
|
||||
nightly-only fixtures (`fixtures/nightly/targets.json`: CODESYS archives, a
|
||||
ladder diagram, a live PLC endpoint, a corrupt archive), which the harness
|
||||
onboards through the API. The real CODESYS sample is not committed; point
|
||||
`NIGHTLY_CODESYS_SAMPLE` at it or its target is skipped. To run it against any
|
||||
agent in dev mode (use a fresh database: a rescan of an unchanged repo skips
|
||||
most stages, so it records less than a first scan):
|
||||
|
||||
```bash
|
||||
NIGHTLY_AGENT_URL=http://localhost:3001 \
|
||||
|
||||
@@ -112,6 +112,11 @@ pub struct DemoTarget {
|
||||
pub description: Option<String>,
|
||||
#[serde(default)]
|
||||
pub artifacts: Vec<DemoArtifact>,
|
||||
/// Opt-in scans to switch on before the first scan (`scan_config.
|
||||
/// enabled_scans`, wire names such as `icsprobe`), as a customer would.
|
||||
/// Applied by the nightly harness to the fixtures it onboards itself.
|
||||
#[serde(default)]
|
||||
pub enabled_scans: Vec<String>,
|
||||
/// Golden baseline for the nightly regression.
|
||||
#[serde(default)]
|
||||
pub expect: Expect,
|
||||
@@ -553,6 +558,7 @@ mod tests {
|
||||
plc_format: None,
|
||||
optional: true,
|
||||
}],
|
||||
enabled_scans: Vec::new(),
|
||||
expect: Expect::default(),
|
||||
};
|
||||
assert!(t.source_only());
|
||||
|
||||
@@ -649,6 +649,21 @@ impl PipelineOrchestrator {
|
||||
.stored_path
|
||||
.clone()
|
||||
.unwrap_or_else(|| a.source_ref.clone());
|
||||
// Declared a CODESYS archive but not a readable zip: say so on the
|
||||
// run, instead of completing with an empty SBOM as if it were fine.
|
||||
if a.plc.as_ref().map(|p| p.format) == Some(PlcFormat::ProjectArchive) {
|
||||
if let Err(e) =
|
||||
crate::pipeline::plc::sbom::check_archive(std::path::Path::new(&archive))
|
||||
{
|
||||
let name = a.display_name.as_deref().unwrap_or(&a.source_ref);
|
||||
self.skip_stage(
|
||||
scan_run_id,
|
||||
"plc_archive_sbom",
|
||||
&format!("{name} is not a readable CODESYS project archive: {e}"),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
for e in crate::pipeline::plc::sbom::collect_sbom(
|
||||
std::path::Path::new(&archive),
|
||||
&path,
|
||||
|
||||
@@ -51,6 +51,18 @@ pub fn collect_sbom(artifact_file: &Path, working_path: &Path, repo_id: &str) ->
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether `archive` opens as a zip, i.e. could be a CODESYS project archive.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// The reason it cannot be read, for recording on the scan run.
|
||||
pub fn check_archive(archive: &Path) -> Result<(), String> {
|
||||
let file = std::fs::File::open(archive).map_err(|e| e.to_string())?;
|
||||
zip::ZipArchive::new(file)
|
||||
.map(drop)
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Extract CODESYS library + runtime components from a `.projectarchive` (a zip).
|
||||
/// Best-effort: returns empty if the file is not a readable zip (e.g. a bare
|
||||
/// `.st`/`.xml` project, which carries no library manifest).
|
||||
@@ -174,6 +186,17 @@ mod tests {
|
||||
zip.finish().expect("finish");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_corrupt_archive_is_reported_not_silently_empty() {
|
||||
let tmp = std::env::temp_dir().join(format!("cs-plc-bad-{}", uuid::Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&tmp).expect("mkdir");
|
||||
let bad = tmp.join("Broken.projectarchive");
|
||||
std::fs::write(&bad, b"PK\x03\x04 not a real archive").expect("write");
|
||||
assert!(check_archive(&bad).is_err());
|
||||
assert!(check_archive(&synthetic_archive(&tmp)).is_ok());
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extracts_libraries_and_runtime_from_projectarchive() {
|
||||
let tmp = std::env::temp_dir().join(format!("cs-plc-sbom-{}", uuid::Uuid::new_v4()));
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
//! Nightly scan regression (#188).
|
||||
//!
|
||||
//! Seeds the demo-target corpus on a **running** agent (the nightly job points
|
||||
//! Seeds two corpora on a **running** agent (the nightly job points
|
||||
//! `NIGHTLY_AGENT_URL` at the built image), waits for every scan, and compares
|
||||
//! the results with two baselines per target:
|
||||
//!
|
||||
//! - the hand-written `expect` block in `fixtures/demo-targets/targets.json`:
|
||||
//! invariants such as the rules and CWEs that must appear;
|
||||
//! - the demo targets (`fixtures/demo-targets/targets.json`), which the agent
|
||||
//! seeds itself (`POST /targets/demo-seed`, as the dashboard does), and
|
||||
//! - the nightly-only fixtures (`fixtures/nightly/targets.json`, same schema),
|
||||
//! which the harness onboards through the public API the way a customer does:
|
||||
//! create, upload, detect, scan.
|
||||
//!
|
||||
//! The baselines:
|
||||
//!
|
||||
//! - the hand-written `expect` block in the manifest: invariants such as the
|
||||
//! rules and CWEs that must appear;
|
||||
//! - a blessed snapshot in `fixtures/nightly/baselines/<key>.json`:
|
||||
//! - **exact**: scan status, skipped stages, SBOM components, and findings
|
||||
//! from deterministic scanners (PLC rules, secrets, patterns, lint, our own
|
||||
@@ -20,9 +28,10 @@
|
||||
//! `cargo test` never needs a running agent.
|
||||
//!
|
||||
//! Other settings: `NIGHTLY_AGENT_TOKEN` (bearer, for a hardened agent),
|
||||
//! `NIGHTLY_ONLY` (comma-separated target keys), `NIGHTLY_TIMEOUT_SECS`
|
||||
//! (default 1500). The report and this run's snapshots are written to
|
||||
//! `target/nightly/`.
|
||||
//! `NIGHTLY_ONLY` (comma-separated target keys from either manifest),
|
||||
//! `NIGHTLY_TIMEOUT_SECS` (default 1500), and the env vars an optional fixture
|
||||
//! names (e.g. `NIGHTLY_CODESYS_SAMPLE`; the target is skipped without it). The
|
||||
//! report and this run's snapshots are written to `target/nightly/`.
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
@@ -33,7 +42,7 @@ use std::time::{Duration, Instant};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use compliance_agent::fixtures::{DemoTarget, DemoTargets, Observed};
|
||||
use compliance_agent::fixtures::{DemoArtifact, DemoTarget, DemoTargets, Observed};
|
||||
|
||||
/// Page size the agent allows at most (`MAX_PAGE_SIZE`).
|
||||
const PAGE: usize = 200;
|
||||
@@ -65,9 +74,46 @@ impl Agent {
|
||||
let status = resp.status();
|
||||
let text = resp.text().await.unwrap_or_default();
|
||||
assert!(status.is_success(), "{method} {path}: {status} {text}");
|
||||
if text.trim().is_empty() {
|
||||
return Value::Null;
|
||||
}
|
||||
serde_json::from_str(&text).unwrap_or_else(|e| panic!("{method} {path}: {e}: {text}"))
|
||||
}
|
||||
|
||||
async fn post(&self, path: &str, body: Value) -> Value {
|
||||
self.call(reqwest::Method::POST, path, Some(body)).await
|
||||
}
|
||||
|
||||
/// Upload one file artifact the way the dashboard does (multipart).
|
||||
async fn upload(&self, target_id: &str, a: &DemoArtifact, path: &Path) -> Result<(), String> {
|
||||
let bytes = tokio::fs::read(path)
|
||||
.await
|
||||
.map_err(|e| format!("reading {}: {e}", path.display()))?;
|
||||
let filename = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or_default();
|
||||
let mut form = reqwest::multipart::Form::new()
|
||||
.text("kind", serde_name(&a.kind))
|
||||
.part(
|
||||
"file",
|
||||
reqwest::multipart::Part::bytes(bytes).file_name(filename),
|
||||
);
|
||||
if let Some(format) = &a.plc_format {
|
||||
form = form.text("plc_format", serde_name(format));
|
||||
}
|
||||
let url = format!("{}/api/v1/targets/{target_id}/artifacts/upload", self.base);
|
||||
let mut req = self.http.post(url).multipart(form);
|
||||
if let Some(t) = &self.token {
|
||||
req = req.bearer_auth(t);
|
||||
}
|
||||
let resp = req.send().await.map_err(|e| format!("upload: {e}"))?;
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("upload {} -> {}", path.display(), resp.status()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(&self, path: &str) -> Value {
|
||||
self.call(reqwest::Method::GET, path, None).await
|
||||
}
|
||||
@@ -104,6 +150,107 @@ fn text(v: &Value, key: &str) -> String {
|
||||
v[key].as_str().unwrap_or_default().to_string()
|
||||
}
|
||||
|
||||
/// The wire name of a snake_case enum (`plc_project`, `project_archive`).
|
||||
fn serde_name<T: Serialize>(value: &T) -> String {
|
||||
serde_json::to_value(value)
|
||||
.ok()
|
||||
.and_then(|v| v.as_str().map(str::to_string))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The keys of `manifest` that this run covers (all of them when `only` is
|
||||
/// empty).
|
||||
fn keys_in(manifest: &DemoTargets, only: &[String]) -> Vec<String> {
|
||||
manifest
|
||||
.targets
|
||||
.iter()
|
||||
.map(|t| t.key.clone())
|
||||
.filter(|k| only.is_empty() || only.contains(k))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Onboard one nightly-only fixture through the public API, as a customer
|
||||
/// would, and start its scan; an existing target of the same name is only
|
||||
/// rescanned. `Ok(None)` when an optional file is missing and nothing is left
|
||||
/// to scan.
|
||||
async fn seed_nightly(
|
||||
agent: &Agent,
|
||||
root: &Path,
|
||||
manifest: &DemoTargets,
|
||||
t: &DemoTarget,
|
||||
) -> Result<Option<String>, String> {
|
||||
let name = manifest.full_name(t);
|
||||
let mut uploads = Vec::new();
|
||||
for a in t.artifacts.iter().filter(|a| a.is_upload()) {
|
||||
match a.upload_path(root) {
|
||||
Some(path) => uploads.push((a, path)),
|
||||
None if a.optional => {}
|
||||
None => return Err(format!("{:?} artifact has no file", a.kind)),
|
||||
}
|
||||
}
|
||||
let references: Vec<Value> = t
|
||||
.artifacts
|
||||
.iter()
|
||||
.filter(|a| !a.is_upload())
|
||||
.filter_map(|a| {
|
||||
a.resolved_source_ref().map(|source_ref| {
|
||||
json!({
|
||||
"kind": a.kind,
|
||||
"source_ref": source_ref,
|
||||
"branch": a.branch,
|
||||
"plc_format": a.plc_format,
|
||||
})
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
if uploads.is_empty() && references.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let existing = agent
|
||||
.all("/api/v1/targets")
|
||||
.await
|
||||
.into_iter()
|
||||
.find(|v| text(v, "name") == name);
|
||||
let id = match existing {
|
||||
Some(target) => oid(&target),
|
||||
None => {
|
||||
let created = agent
|
||||
.post(
|
||||
"/api/v1/targets",
|
||||
json!({
|
||||
"name": name,
|
||||
"target_type": t.target_type,
|
||||
"description": t.description,
|
||||
"artifacts": references,
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let id = oid(&created["data"]);
|
||||
for (a, path) in &uploads {
|
||||
agent.upload(&id, a, path).await?;
|
||||
}
|
||||
if !t.enabled_scans.is_empty() {
|
||||
agent
|
||||
.call(
|
||||
reqwest::Method::PATCH,
|
||||
&format!("/api/v1/targets/{id}"),
|
||||
Some(json!({ "scan_config": { "enabled_scans": t.enabled_scans } })),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
agent
|
||||
.post(&format!("/api/v1/targets/{id}/detect"), json!({}))
|
||||
.await;
|
||||
id
|
||||
}
|
||||
};
|
||||
agent
|
||||
.post(&format!("/api/v1/targets/{id}/scan"), json!({}))
|
||||
.await;
|
||||
Ok(Some(id))
|
||||
}
|
||||
|
||||
/// A semgrep rule id is prefixed with the path of the config it came from; our
|
||||
/// own rules are recognised by their `cra-ai-` id wherever it sits.
|
||||
fn normalise_rule(scanner: &str, rule: &str) -> String {
|
||||
@@ -117,6 +264,9 @@ fn normalise_rule(scanner: &str, rule: &str) -> String {
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
struct Snapshot {
|
||||
scan_status: String,
|
||||
/// The run's error message, for fixtures that must fail cleanly.
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
error: String,
|
||||
skipped_stages: BTreeSet<String>,
|
||||
/// `package_manager:name@version`, compared exactly.
|
||||
sbom: BTreeSet<String>,
|
||||
@@ -138,6 +288,12 @@ impl Snapshot {
|
||||
self.scan_status, baseline.scan_status
|
||||
));
|
||||
}
|
||||
if self.error != baseline.error {
|
||||
out.push(format!(
|
||||
"error \"{}\", blessed \"{}\"",
|
||||
self.error, baseline.error
|
||||
));
|
||||
}
|
||||
let exact = |what: &str, got: &BTreeSet<String>, want: &BTreeSet<String>| {
|
||||
let mut lines: Vec<String> = want
|
||||
.difference(got)
|
||||
@@ -192,6 +348,7 @@ async fn collect(agent: &Agent, target_id: &str, run: &Value) -> Collected {
|
||||
|
||||
let mut snapshot = Snapshot {
|
||||
scan_status: text(run, "status"),
|
||||
error: text(run, "error_message"),
|
||||
skipped_stages: run["skipped_stages"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
@@ -348,8 +505,22 @@ async fn nightly_scan_regression() {
|
||||
token: std::env::var("NIGHTLY_AGENT_TOKEN").ok(),
|
||||
};
|
||||
let root = DemoTargets::workspace_root();
|
||||
let manifest = DemoTargets::load().expect("manifest");
|
||||
let selected: Vec<&DemoTarget> = manifest.select(&only).expect("targets");
|
||||
let demo = DemoTargets::load().expect("demo manifest");
|
||||
let nightly = DemoTargets::load_from(&root.join("fixtures/nightly/targets.json"))
|
||||
.expect("nightly manifest");
|
||||
let demo_keys = keys_in(&demo, &only);
|
||||
let nightly_keys = keys_in(&nightly, &only);
|
||||
let selected: Vec<&DemoTarget> = demo
|
||||
.targets
|
||||
.iter()
|
||||
.filter(|t| demo_keys.contains(&t.key))
|
||||
.chain(
|
||||
nightly
|
||||
.targets
|
||||
.iter()
|
||||
.filter(|t| nightly_keys.contains(&t.key)),
|
||||
)
|
||||
.collect();
|
||||
|
||||
// Seed (or rescan) every selected target, noting the runs that existed.
|
||||
let before: BTreeSet<String> = agent
|
||||
@@ -358,25 +529,45 @@ async fn nightly_scan_regression() {
|
||||
.iter()
|
||||
.map(oid)
|
||||
.collect();
|
||||
let seeded = agent
|
||||
.call(
|
||||
reqwest::Method::POST,
|
||||
"/api/v1/targets/demo-seed",
|
||||
Some(json!({ "names": only, "rescan": true })),
|
||||
)
|
||||
.await;
|
||||
let mut failures: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
||||
let mut skipped: Vec<String> = Vec::new();
|
||||
let mut ids: BTreeMap<String, String> = BTreeMap::new();
|
||||
for s in seeded["seeded"].as_array().into_iter().flatten() {
|
||||
let key = text(s, "name");
|
||||
match s["target_id"].as_str() {
|
||||
Some(id) if text(s, "status") != "failed" => {
|
||||
ids.insert(key, id.to_string());
|
||||
// An empty name list would seed every demo target, so skip the call when
|
||||
// this run covers none of them.
|
||||
if !demo_keys.is_empty() {
|
||||
let seeded = agent
|
||||
.post(
|
||||
"/api/v1/targets/demo-seed",
|
||||
json!({ "names": demo_keys, "rescan": true }),
|
||||
)
|
||||
.await;
|
||||
for s in seeded["seeded"].as_array().into_iter().flatten() {
|
||||
let key = text(s, "name");
|
||||
match s["target_id"].as_str() {
|
||||
Some(id) if text(s, "status") != "failed" => {
|
||||
ids.insert(key, id.to_string());
|
||||
}
|
||||
_ => failures
|
||||
.entry(key)
|
||||
.or_default()
|
||||
.push(format!("seeding failed: {}", text(s, "error"))),
|
||||
}
|
||||
_ => failures
|
||||
.entry(key)
|
||||
}
|
||||
}
|
||||
for t in nightly
|
||||
.targets
|
||||
.iter()
|
||||
.filter(|t| nightly_keys.contains(&t.key))
|
||||
{
|
||||
match seed_nightly(&agent, &root, &nightly, t).await {
|
||||
Ok(Some(id)) => {
|
||||
ids.insert(t.key.clone(), id);
|
||||
}
|
||||
Ok(None) => skipped.push(t.key.clone()),
|
||||
Err(e) => failures
|
||||
.entry(t.key.clone())
|
||||
.or_default()
|
||||
.push(format!("seeding failed: {}", text(s, "error"))),
|
||||
.push(format!("seeding failed: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,6 +576,11 @@ async fn nightly_scan_regression() {
|
||||
|
||||
let report_dir = root.join("target/nightly");
|
||||
let mut report = String::from("# Nightly scan regression\n\n");
|
||||
for key in &skipped {
|
||||
report.push_str(&format!(
|
||||
"## {key} (skipped)\n\nAn optional fixture file is not available here.\n\n"
|
||||
));
|
||||
}
|
||||
for t in &selected {
|
||||
let Some(id) = ids.get(&t.key) else { continue };
|
||||
let Some(run) = runs.get(id) else {
|
||||
@@ -463,6 +659,7 @@ mod unit {
|
||||
fn exact_sets_report_both_directions_and_at_least_sets_only_losses() {
|
||||
let blessed = Snapshot {
|
||||
scan_status: "completed".into(),
|
||||
error: String::new(),
|
||||
skipped_stages: set(&["dast"]),
|
||||
sbom: set(&["cargo:itoa@1.0.15"]),
|
||||
findings: set(&["gitleaks:aws-key a.py:3"]),
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [],
|
||||
"sbom": [
|
||||
"codesys:3SLicense@3.5.20.0",
|
||||
"codesys:Base Interfaces@3.5.17.0",
|
||||
"codesys:Breakpoint Logging Functions@3.5.17.0",
|
||||
"codesys:CAA Behaviour Model@3.5.19.0",
|
||||
"codesys:CAA Tick Extern@3.5.17.0",
|
||||
"codesys:CAA TickUtil Extern@3.5.17.0",
|
||||
"codesys:CAA Types Extern@3.5.17.0",
|
||||
"codesys:CODESYS Control for Linux ARM SL@4.17.0.0",
|
||||
"codesys:CSV Utility SL@1.9.0.0",
|
||||
"codesys:CmpApp@3.5.21.0",
|
||||
"codesys:CmpCodeMeter@3.5.18.0",
|
||||
"codesys:CmpErrors2 Interfaces@3.5.21.0",
|
||||
"codesys:CmpEventMgr Implementation@3.5.17.0",
|
||||
"codesys:CmpEventMgr Interfaces@3.5.17.0",
|
||||
"codesys:CmpEventMgr@3.5.17.0",
|
||||
"codesys:CmpIoMgr Implementation@3.5.17.0",
|
||||
"codesys:CmpIoMgr Interfaces@3.5.19.30",
|
||||
"codesys:CmpLog@3.5.21.0",
|
||||
"codesys:CmpSchedule@3.5.17.0",
|
||||
"codesys:Component Manager@3.5.21.0",
|
||||
"codesys:IoStandard@3.5.17.0",
|
||||
"codesys:Standard@3.5.18.0",
|
||||
"codesys:StringUtils@3.5.20.0",
|
||||
"codesys:SysCpuHandling@3.5.17.0",
|
||||
"codesys:SysDir@3.5.17.0",
|
||||
"codesys:SysFile@3.5.17.0",
|
||||
"codesys:SysMem@3.5.17.0",
|
||||
"codesys:SysTime@3.5.17.0",
|
||||
"codesys:SysTimeCore@3.5.17.0",
|
||||
"codesys:SysTimeRtc@3.5.20.0",
|
||||
"codesys:SysTypes2 Interfaces@3.5.17.0",
|
||||
"codesys:System%25124 DonutChart@1.0.0.0",
|
||||
"codesys:System%25124 HTML5DemoGauge@1.0.0.0",
|
||||
"codesys:System%25124 HTML5DemoTableNoScrollRange@1.0.0.0",
|
||||
"codesys:System%25124 RoundSlider@1.0.0.0",
|
||||
"codesys:Util@3.5.21.0",
|
||||
"codesys:VisuSymbols@4.5.0.0"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [
|
||||
"CVE-2022-4046",
|
||||
"CVE-2025-41738"
|
||||
],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [],
|
||||
"sbom": [
|
||||
"codesys:3SLicense@3.5.16.0",
|
||||
"codesys:CODESYS Control for Linux SL@3.5.16.0",
|
||||
"codesys:CmpCodeMeter@3.5.16.0",
|
||||
"codesys:Standard@3.5.16.0",
|
||||
"codesys:SysSocket@3.5.16.0",
|
||||
"codesys:Util@3.5.16.0"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [
|
||||
"CVE-2020-15806",
|
||||
"CVE-2021-21863",
|
||||
"CVE-2021-21864",
|
||||
"CVE-2021-21865",
|
||||
"CVE-2021-21866",
|
||||
"CVE-2021-21867",
|
||||
"CVE-2021-21868",
|
||||
"CVE-2021-21869",
|
||||
"CVE-2021-29239",
|
||||
"CVE-2021-29240",
|
||||
"CVE-2021-29241",
|
||||
"CVE-2021-29242",
|
||||
"CVE-2021-33485",
|
||||
"CVE-2021-33486",
|
||||
"CVE-2021-36763",
|
||||
"CVE-2021-36764",
|
||||
"CVE-2021-36765",
|
||||
"CVE-2022-1794",
|
||||
"CVE-2022-22508",
|
||||
"CVE-2022-22513",
|
||||
"CVE-2022-22514",
|
||||
"CVE-2022-22515",
|
||||
"CVE-2022-22516",
|
||||
"CVE-2022-22517",
|
||||
"CVE-2022-22519",
|
||||
"CVE-2022-30791",
|
||||
"CVE-2022-30792",
|
||||
"CVE-2022-31805",
|
||||
"CVE-2022-4046",
|
||||
"CVE-2022-4048",
|
||||
"CVE-2022-4224",
|
||||
"CVE-2022-47378",
|
||||
"CVE-2022-47379",
|
||||
"CVE-2022-47380",
|
||||
"CVE-2022-47381",
|
||||
"CVE-2022-47382",
|
||||
"CVE-2022-47383",
|
||||
"CVE-2022-47384",
|
||||
"CVE-2022-47385",
|
||||
"CVE-2022-47386",
|
||||
"CVE-2022-47387",
|
||||
"CVE-2022-47388",
|
||||
"CVE-2022-47389",
|
||||
"CVE-2022-47390",
|
||||
"CVE-2022-47391",
|
||||
"CVE-2022-47392",
|
||||
"CVE-2022-47393",
|
||||
"CVE-2023-3663",
|
||||
"CVE-2023-3669",
|
||||
"CVE-2023-3670",
|
||||
"CVE-2023-37545",
|
||||
"CVE-2023-37546",
|
||||
"CVE-2023-37547",
|
||||
"CVE-2023-37548",
|
||||
"CVE-2023-37549",
|
||||
"CVE-2023-37550",
|
||||
"CVE-2023-37551",
|
||||
"CVE-2023-37552",
|
||||
"CVE-2023-37553",
|
||||
"CVE-2023-37554",
|
||||
"CVE-2023-37555",
|
||||
"CVE-2023-37556",
|
||||
"CVE-2023-37557",
|
||||
"CVE-2023-37558",
|
||||
"CVE-2023-37559",
|
||||
"CVE-2023-6357",
|
||||
"CVE-2025-41700",
|
||||
"CVE-2026-0393",
|
||||
"CVE-2026-44468",
|
||||
"CVE-2026-44469"
|
||||
],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"plc_archive_sbom"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [],
|
||||
"sbom": [],
|
||||
"findings": [
|
||||
"plc-control-logic:plc-hardcoded-credential mixer_ld.xml:9",
|
||||
"plc-control-logic:plc-insecure-comm mixer_ld.xml:7",
|
||||
"plc-control-logic:plc-insecure-protocol-port mixer_ld.xml:7",
|
||||
"plc-control-logic:plc-insecure-protocol-port mixer_ld.xml:8"
|
||||
],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"ics_probe"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [
|
||||
"plc-control-logic:plc-hardcoded-credential traffic_light.st:34",
|
||||
"plc-control-logic:plc-insecure-comm traffic_light.st:45",
|
||||
"plc-control-logic:plc-insecure-protocol-port traffic_light.st:45",
|
||||
"plc-control-logic:plc-safety-bypass traffic_light.st:59"
|
||||
],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Nightly fixture (#314): a PLCopen program whose body is a Ladder Diagram.
|
||||
Planted defects: an unauthenticated Modbus server on 502, an FTP transfer
|
||||
on 21, and a login block with a literal, default password. -->
|
||||
<project xmlns="http://www.plcopen.org/xml/tc6_0201">
|
||||
<types><pous>
|
||||
<pou name="MixerControl" pouType="program">
|
||||
<interface><localVars>
|
||||
<variable name="Mixer_Run"><type><BOOL/></type></variable>
|
||||
<variable name="Start"><type><BOOL/></type></variable>
|
||||
</localVars></interface>
|
||||
<body><LD>
|
||||
<leftPowerRail localId="0"/>
|
||||
<contact localId="1"><variable>Start</variable>
|
||||
<connectionPointIn><connection refLocalId="0"/></connectionPointIn></contact>
|
||||
<coil localId="2"><variable>Mixer_Run</variable>
|
||||
<connectionPointIn><connection refLocalId="1"/></connectionPointIn></coil>
|
||||
|
||||
<inVariable localId="3"><expression>502</expression></inVariable>
|
||||
<inVariable localId="4"><expression>FALSE</expression></inVariable>
|
||||
<block localId="10" typeName="Modbus_TCP_Server">
|
||||
<inputVariables>
|
||||
<variable formalParameter="PORT">
|
||||
<connectionPointIn><connection refLocalId="3"/></connectionPointIn></variable>
|
||||
<variable formalParameter="AUTH">
|
||||
<connectionPointIn><connection refLocalId="4"/></connectionPointIn></variable>
|
||||
</inputVariables>
|
||||
</block>
|
||||
|
||||
<inVariable localId="5"><expression>21</expression></inVariable>
|
||||
<block localId="11" typeName="Ftp_Send">
|
||||
<inputVariables>
|
||||
<variable formalParameter="PORT">
|
||||
<connectionPointIn><connection refLocalId="5"/></connectionPointIn></variable>
|
||||
</inputVariables>
|
||||
</block>
|
||||
|
||||
<inVariable localId="6"><expression>'operator'</expression></inVariable>
|
||||
<inVariable localId="7"><expression>'admin'</expression></inVariable>
|
||||
<block localId="12" typeName="SysUser_Login">
|
||||
<inputVariables>
|
||||
<variable formalParameter="USER">
|
||||
<connectionPointIn><connection refLocalId="6"/></connectionPointIn></variable>
|
||||
<variable formalParameter="PASSWORD">
|
||||
<connectionPointIn><connection refLocalId="7"/></connectionPointIn></variable>
|
||||
</inputVariables>
|
||||
</block>
|
||||
</LD></body>
|
||||
</pou>
|
||||
</pous></types>
|
||||
</project>
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name_prefix": "Nightly · ",
|
||||
"targets": [
|
||||
{
|
||||
"key": "plc-codesys-synthetic",
|
||||
"name": "CODESYS archive (synthetic, old runtime)",
|
||||
"target_type": "plc_sps",
|
||||
"description": "Small synthetic .projectarchive with the real CODESYS entry naming and an old runtime (3.5.16.0), so the library SBOM is exact and the NVD CPE match has known CVEs.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "plc_project",
|
||||
"upload": "fixtures/nightly/plc/line_control.projectarchive",
|
||||
"plc_format": "project_archive"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"min_sbom_components": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "plc-codesys-proemion",
|
||||
"name": "CODESYS archive (Proemion CSV-BlackBox sample)",
|
||||
"target_type": "plc_sps",
|
||||
"description": "Real CODESYS project archive from Proemion/codesys-examples (Apache-2.0). Not committed (~10 MB): the nightly job downloads it at a pinned commit and sha256 into NIGHTLY_CODESYS_SAMPLE; skipped where that is unset.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "plc_project",
|
||||
"upload_env": "NIGHTLY_CODESYS_SAMPLE",
|
||||
"plc_format": "project_archive",
|
||||
"optional": true,
|
||||
"pin": "164d8eea7b7483f764b4959788fd2a733624e576"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"min_sbom_components": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "plc-ladder",
|
||||
"name": "PLCopen ladder diagram",
|
||||
"target_type": "plc_sps",
|
||||
"description": "A PLCopen program whose body is a Ladder Diagram, translated to ST before analysis. Planted: unauthenticated Modbus server on 502, FTP on 21, a login block with a default password.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "plc_project",
|
||||
"upload": "fixtures/nightly/plc/mixer_ld.xml",
|
||||
"plc_format": "plcopen_xml"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"sast_rule_ids": [
|
||||
"plc-insecure-protocol-port",
|
||||
"plc-insecure-comm"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "plc-live-endpoint",
|
||||
"name": "PLC with a live endpoint (source_only)",
|
||||
"target_type": "plc_sps",
|
||||
"description": "Structured Text plus a public-looking Modbus endpoint, with the (opt-in) ICS probe switched on. Under PW_FEATURES=source_only the probe must be recorded as a skipped stage, and the endpoint is never contacted.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "plc_project",
|
||||
"upload": "examples/plc-demo/traffic_light.st",
|
||||
"plc_format": "structured_text"
|
||||
},
|
||||
{
|
||||
"kind": "live_url",
|
||||
"source_ref": "modbus://plc.example.com:502"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"sast_rule_ids": [
|
||||
"plc-hardcoded-credential",
|
||||
"plc-safety-bypass"
|
||||
]
|
||||
},
|
||||
"enabled_scans": [
|
||||
"icsprobe"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "plc-corrupt-archive",
|
||||
"name": "Corrupt CODESYS archive",
|
||||
"target_type": "plc_sps",
|
||||
"description": "A .projectarchive that is not a valid zip. The scan must fail cleanly with a clear error, never hang or crash the agent.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "plc_project",
|
||||
"upload": "fixtures/nightly/plc/corrupt.projectarchive",
|
||||
"plc_format": "project_archive"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user