feat: Implement Filesystem and MongoDB provenance writers for PackRun execution context
- Added `FilesystemPackRunProvenanceWriter` to write provenance manifests to the filesystem. - Introduced `MongoPackRunArtifactReader` to read artifacts from MongoDB. - Created `MongoPackRunProvenanceWriter` to store provenance manifests in MongoDB. - Developed unit tests for filesystem and MongoDB provenance writers. - Established `ITimelineEventStore` and `ITimelineIngestionService` interfaces for timeline event handling. - Implemented `TimelineIngestionService` to validate and persist timeline events with hashing. - Created PostgreSQL schema and migration scripts for timeline indexing. - Added dependency injection support for timeline indexer services. - Developed tests for timeline ingestion and schema validation.
This commit is contained in:
38
bench/reachability-benchmark/cases/js/guarded-eval/case.yaml
Normal file
38
bench/reachability-benchmark/cases/js/guarded-eval/case.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
id: "js-guarded-eval:002"
|
||||
language: js
|
||||
project: guarded-eval
|
||||
version: "1.0.0"
|
||||
description: "Eval sink guarded by FEATURE_ENABLE flag; unreachable when flag is off"
|
||||
entrypoints:
|
||||
- "POST /api/exec"
|
||||
sinks:
|
||||
- id: "GuardedEval::handleRequest"
|
||||
path: "src/app.js::handleRequest"
|
||||
kind: "process"
|
||||
location:
|
||||
file: src/app.js
|
||||
line: 13
|
||||
notes: "eval on user input guarded by FEATURE_ENABLE"
|
||||
environment:
|
||||
os_image: "node:20-alpine"
|
||||
runtime:
|
||||
node: "20.11.0"
|
||||
source_date_epoch: 1730000000
|
||||
build:
|
||||
command: "./build/build.sh"
|
||||
source_date_epoch: 1730000000
|
||||
outputs:
|
||||
artifact_path: outputs/binary.tar.gz
|
||||
sbom_path: outputs/sbom.cdx.json
|
||||
coverage_path: outputs/coverage.json
|
||||
traces_dir: outputs/traces
|
||||
test:
|
||||
command: "./tests/run-tests.sh"
|
||||
expected_coverage:
|
||||
- outputs/coverage.json
|
||||
expected_traces:
|
||||
- outputs/traces/traces.json
|
||||
ground_truth:
|
||||
summary: "Guard prevents sink when FEATURE_ENABLE != 1"
|
||||
evidence_files:
|
||||
- "../benchmark/truth/js-guarded-eval.json"
|
||||
@@ -0,0 +1,8 @@
|
||||
case_id: "js-guarded-eval:002"
|
||||
entries:
|
||||
http:
|
||||
- id: "POST /api/exec"
|
||||
route: "/api/exec"
|
||||
method: "POST"
|
||||
handler: "app.js::handleRequest"
|
||||
description: "Feature-flagged code execution endpoint"
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "rb-case-guarded-eval",
|
||||
"version": "1.0.0",
|
||||
"description": "Reachability benchmark case: eval guarded by feature flag",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "./tests/run-tests.sh"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
function handleRequest(body, env = process.env) {
|
||||
if (env.FEATURE_ENABLE !== '1') {
|
||||
return { status: 403, body: 'disabled' };
|
||||
}
|
||||
|
||||
const code = body && body.code;
|
||||
if (typeof code !== 'string') {
|
||||
return { status: 400, body: 'bad request' };
|
||||
}
|
||||
|
||||
// This sink is reachable only when FEATURE_ENABLE=1.
|
||||
// eslint-disable-next-line no-eval
|
||||
const result = eval(code);
|
||||
return { status: 200, body: String(result) };
|
||||
}
|
||||
|
||||
module.exports = { handleRequest };
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-1730000000}
|
||||
export TZ=UTC
|
||||
export LC_ALL=C
|
||||
node test_unreachable.js
|
||||
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { handleRequest } = require('../src/app');
|
||||
|
||||
const OUT_DIR = path.resolve(__dirname, '../outputs');
|
||||
const TRACE_DIR = path.join(OUT_DIR, 'traces');
|
||||
const COVERAGE_FILE = path.join(OUT_DIR, 'coverage.json');
|
||||
const TRACE_FILE = path.join(TRACE_DIR, 'traces.json');
|
||||
|
||||
function ensureDirs() {
|
||||
fs.mkdirSync(OUT_DIR, { recursive: true });
|
||||
fs.mkdirSync(TRACE_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
function recordTrace(entry, pathNodes) {
|
||||
fs.writeFileSync(
|
||||
TRACE_FILE,
|
||||
JSON.stringify({
|
||||
entry,
|
||||
path: pathNodes,
|
||||
sink: 'GuardedEval::handleRequest',
|
||||
notes: 'Guard prevented sink execution'
|
||||
}, null, 2)
|
||||
);
|
||||
}
|
||||
|
||||
function recordCoverage(filePath, lines) {
|
||||
fs.writeFileSync(
|
||||
COVERAGE_FILE,
|
||||
JSON.stringify({
|
||||
files: {
|
||||
[filePath]: {
|
||||
lines_covered: lines,
|
||||
lines_total: 32
|
||||
}
|
||||
}
|
||||
}, null, 2)
|
||||
);
|
||||
}
|
||||
|
||||
(function main() {
|
||||
ensureDirs();
|
||||
const payload = { code: '1 + 2' };
|
||||
const response = handleRequest(payload, { FEATURE_ENABLE: '0' });
|
||||
assert.strictEqual(response.status, 403);
|
||||
assert.strictEqual(response.body, 'disabled');
|
||||
|
||||
// Record that the guard path was taken; no SINK_REACHED marker is written.
|
||||
recordTrace('POST /api/exec', ['app.js:handleRequest', 'guard: FEATURE_ENABLE != 1']);
|
||||
recordCoverage('src/app.js', [5, 6, 7, 9, 10, 11]);
|
||||
})();
|
||||
Reference in New Issue
Block a user