Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1484e1074 |
No files matched your search
@@ -250,16 +250,14 @@ pub async fn export(
|
|||||||
|
|
||||||
/// `DELETE /api/v1/platform/tenants/{id}/data` — GDPR erasure: drops the
|
/// `DELETE /api/v1/platform/tenants/{id}/data` — GDPR erasure: drops the
|
||||||
/// tenant database and removes its code from disk (clones, uploads, work
|
/// tenant database and removes its code from disk (clones, uploads, work
|
||||||
/// trees, blobs, runner artifacts). Requires `{"confirm": "<tenant id>"}`:
|
/// trees, blobs, runner artifacts). Requires `{"confirm": "<slug or id>"}`.
|
||||||
/// the same id as in the path, so a call can only erase the tenant it names
|
|
||||||
/// twice; anything else is refused with 400 before anything is touched.
|
|
||||||
pub async fn delete_data(
|
pub async fn delete_data(
|
||||||
State(st): State<PlatformState>,
|
State(st): State<PlatformState>,
|
||||||
Path(tenant_id): Path<String>,
|
Path(tenant_id): Path<String>,
|
||||||
body: Option<Json<LifecycleBody>>,
|
body: Option<Json<LifecycleBody>>,
|
||||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||||
let confirm = body.and_then(|Json(b)| b.confirm);
|
let confirm = body.and_then(|Json(b)| b.confirm).unwrap_or_default();
|
||||||
if !confirms_erasure(&tenant_id, confirm.as_deref()) {
|
if confirm.is_empty() {
|
||||||
return Err(StatusCode::BAD_REQUEST);
|
return Err(StatusCode::BAD_REQUEST);
|
||||||
}
|
}
|
||||||
// Where the tenant's code lies on disk, read before its records go.
|
// Where the tenant's code lies on disk, read before its records go.
|
||||||
@@ -301,12 +299,6 @@ pub async fn delete_data(
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether `confirm` confirms erasing `tenant_id`: it must be that id,
|
|
||||||
/// exactly. A missing or empty value, or another tenant's id, does not.
|
|
||||||
fn confirms_erasure(tenant_id: &str, confirm: Option<&str>) -> bool {
|
|
||||||
!tenant_id.is_empty() && confirm == Some(tenant_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `POST /api/v1/platform/tenants/demo/reset` — drops and re-creates the
|
/// `POST /api/v1/platform/tenants/demo/reset` — drops and re-creates the
|
||||||
/// demo tenant database. With `{"seed": true}` it then re-seeds the bundled
|
/// demo tenant database. With `{"seed": true}` it then re-seeds the bundled
|
||||||
/// demo targets and starts their scans, which is what the nightly reset of the
|
/// demo targets and starts their scans, which is what the nightly reset of the
|
||||||
@@ -856,20 +848,3 @@ mod target_count_tests {
|
|||||||
assert!(stages[0].contains_key("$match") && stages[1].contains_key("$group"));
|
assert!(stages[0].contains_key("$match") && stages[1].contains_key("$group"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod erasure_tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn only_the_tenants_own_id_confirms_its_erasure() {
|
|
||||||
assert!(confirms_erasure("t-1", Some("t-1")));
|
|
||||||
assert!(!confirms_erasure("t-1", None));
|
|
||||||
assert!(!confirms_erasure("t-1", Some("")));
|
|
||||||
assert!(!confirms_erasure("t-1", Some("t-2")));
|
|
||||||
assert!(!confirms_erasure("t-1", Some("T-1")));
|
|
||||||
assert!(!confirms_erasure("t-1", Some(" t-1")));
|
|
||||||
assert!(!confirms_erasure("t-1", Some("yes")));
|
|
||||||
assert!(!confirms_erasure("", Some("")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -167,7 +167,6 @@ async fn seed_one(
|
|||||||
compliance_core::models::OnboardedTarget::new(full_name.to_string(), demo.target_type);
|
compliance_core::models::OnboardedTarget::new(full_name.to_string(), demo.target_type);
|
||||||
target.description = demo.description.clone();
|
target.description = demo.description.clone();
|
||||||
target.demo = true;
|
target.demo = true;
|
||||||
target.devices = demo.devices.clone();
|
|
||||||
for a in demo.artifacts.iter().filter(|a| !a.is_upload()) {
|
for a in demo.artifacts.iter().filter(|a| !a.is_upload()) {
|
||||||
match a.resolved_source_ref() {
|
match a.resolved_source_ref() {
|
||||||
Some(source_ref) => target.artifacts.push(targets::reference_artifact(
|
Some(source_ref) => target.artifacts.push(targets::reference_artifact(
|
||||||
|
|||||||
@@ -117,10 +117,6 @@ pub struct DemoTarget {
|
|||||||
/// Applied by the nightly harness to the fixtures it onboards itself.
|
/// Applied by the nightly harness to the fixtures it onboards itself.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub enabled_scans: Vec<String>,
|
pub enabled_scans: Vec<String>,
|
||||||
/// Siemens controllers the target runs on (SPS item 4a), stored with the
|
|
||||||
/// target so its SBOM lists them and Siemens' advisories match them.
|
|
||||||
#[serde(default)]
|
|
||||||
pub devices: Vec<compliance_core::models::PlcDevice>,
|
|
||||||
/// Golden baseline for the nightly regression.
|
/// Golden baseline for the nightly regression.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub expect: Expect,
|
pub expect: Expect,
|
||||||
@@ -495,32 +491,6 @@ mod tests {
|
|||||||
assert_eq!(on_disk.name_prefix, bundled.name_prefix);
|
assert_eq!(on_disk.name_prefix, bundled.name_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn demo_devices_are_stored_as_the_api_would_store_them() {
|
|
||||||
// Arrange
|
|
||||||
let m = manifest();
|
|
||||||
let pump = m
|
|
||||||
.targets
|
|
||||||
.iter()
|
|
||||||
.find(|t| t.key == "plc-pump-station")
|
|
||||||
.expect("pump station in the manifest");
|
|
||||||
|
|
||||||
// Assert: a controller on a firmware Siemens names as affected
|
|
||||||
// (SSA-876787: below V2.9.8), so the demo SBOM is not empty.
|
|
||||||
assert!(!pump.devices.is_empty());
|
|
||||||
for t in &m.targets {
|
|
||||||
for d in &t.devices {
|
|
||||||
let normalised = compliance_core::models::PlcDevice::new(
|
|
||||||
&d.order_number,
|
|
||||||
&d.firmware,
|
|
||||||
d.label.as_deref(),
|
|
||||||
)
|
|
||||||
.expect("a valid controller");
|
|
||||||
assert_eq!(&normalised, d, "{}: store it normalised", t.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn manifest_is_well_formed() {
|
fn manifest_is_well_formed() {
|
||||||
let m = manifest();
|
let m = manifest();
|
||||||
@@ -619,7 +589,6 @@ mod tests {
|
|||||||
optional: true,
|
optional: true,
|
||||||
}],
|
}],
|
||||||
enabled_scans: Vec::new(),
|
enabled_scans: Vec::new(),
|
||||||
devices: Vec::new(),
|
|
||||||
expect: Expect::default(),
|
expect: Expect::default(),
|
||||||
};
|
};
|
||||||
assert!(t.source_only());
|
assert!(t.source_only());
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ async fn seed_nightly(
|
|||||||
"target_type": t.target_type,
|
"target_type": t.target_type,
|
||||||
"description": t.description,
|
"description": t.description,
|
||||||
"artifacts": references,
|
"artifacts": references,
|
||||||
"devices": t.devices,
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ What Prüfwerk keeps about a target, where, and when it is removed.
|
|||||||
|
|
||||||
Deleting a target (`DELETE /api/v1/targets/{id}`, or **Delete** on the
|
Deleting a target (`DELETE /api/v1/targets/{id}`, or **Delete** on the
|
||||||
targets page) removes its records and its files. Erasing a tenant
|
targets page) removes its records and its files. Erasing a tenant
|
||||||
(`DELETE /api/v1/platform/tenants/{id}/data` with `{"confirm": "<tenant id>"}`,
|
(`DELETE /api/v1/platform/tenants/{id}/data`, confirmed) drops its database
|
||||||
the same id as in the path) drops its database
|
|
||||||
and removes every file listed above; the response says how many paths were
|
and removes every file listed above; the response says how many paths were
|
||||||
removed and how many could not be. Only paths inside the two configured base
|
removed and how many could not be. Only paths inside the two configured base
|
||||||
directories are ever removed.
|
directories are ever removed.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"key": "plc-pump-station",
|
"key": "plc-pump-station",
|
||||||
"name": "PLC pump station (ST + FBD, composite)",
|
"name": "PLC pump station (ST + FBD, composite)",
|
||||||
"target_type": "plc_sps",
|
"target_type": "plc_sps",
|
||||||
"description": "Composite PlcSps demo: Structured Text + FBD-as-PLCopen-XML control logic, plus an optional live Modbus endpoint (in-cluster plc-sim) and an optional device firmware image. Runs on a Siemens S7-1500 CPU with an old firmware, so its SBOM lists the controller and Siemens' advisories match it. Exercises PLC SAST, ICS probe, semantic control mapping, Siemens advisory matching.",
|
"description": "Composite PlcSps demo: Structured Text + FBD-as-PLCopen-XML control logic, plus an optional live Modbus endpoint (in-cluster plc-sim) and an optional device firmware image. Exercises PLC SAST, ICS probe, semantic control mapping.",
|
||||||
"artifacts": [
|
"artifacts": [
|
||||||
{
|
{
|
||||||
"kind": "plc_project",
|
"kind": "plc_project",
|
||||||
@@ -30,13 +30,6 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"devices": [
|
|
||||||
{
|
|
||||||
"order_number": "6ES7511-1AK02-0AB0",
|
|
||||||
"firmware": "2.9.4",
|
|
||||||
"label": "Pump station CPU"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"expect": {
|
"expect": {
|
||||||
"min_findings": 16,
|
"min_findings": 16,
|
||||||
"sast_rule_ids": [
|
"sast_rule_ids": [
|
||||||
|
|||||||
Reference in new issue
Block a user