diff --git a/benchmark/ruff.toml b/benchmark/ruff.toml index 34da222f..4dcbf7be 100644 --- a/benchmark/ruff.toml +++ b/benchmark/ruff.toml @@ -1,9 +1,4 @@ -# --- Core Settings --- - -# Set line length to 120 characters line-length = 120 - -# Target Python 3.12 target-version = "py312" src = ["src"] @@ -35,7 +30,6 @@ exclude = [ "cdk.out", ] -# --- Formatter Configuration --- [format] quote-style = "double" indent-style = "space" @@ -43,21 +37,15 @@ skip-magic-trailing-comma = false line-ending = "auto" docstring-code-format = true -# --- Linter Settings --- [lint] select = ["ALL"] -# Ignore specific rules or rule categories. -# Now enabling ANN (annotations) and C90 (complexity). -# Docstring (D) rules are enabled via ALL, with specific ignores below. ignore = [ - # --- Categories to Ignore --- - "DJ", # django specific rules (Not needed for FastAPI) + "DJ", # django-specific rules "EXE", # flake8-executable (Checks for shebangs, etc.) "T10", # debugger imports (like `import pdb`) "S", # flake8-bandit (Security rules - enable selectively if needed, can be noisy) - # --- Specific Rules to Ignore --- "D100", # Missing docstring in public module "D101", "D102", @@ -85,28 +73,22 @@ ignore = [ "G004", ] -# Allow autofix for all enabled rules (when --fix is provided) fixable = ["ALL"] unfixable = [] -# --- Rule-Specific Configurations --- - [lint.isort] known-first-party = ["lib", "paths", "execute", "export", "plot"] [lint.mccabe] -# Set max complexity threshold (C90 rules are now enabled) max-complexity = 10 [lint.pydocstyle] -# Enforce Google-style docstrings convention = "google" -# --- Per-File Ignores --- [lint.per-file-ignores] "__init__.py" = [ "F401", # Allow unused imports in __init__.py for re-exporting "D104", - "D107", # Missing docstring in __init__ # Allow missing docstrings in public packages (__init__.py) + "D107", # Missing docstring in __init__ ] "tests/**/*.py" = [ diff --git a/benchmark/src/plot.py b/benchmark/src/plot.py index 72a5bc73..1f2ac845 100644 --- a/benchmark/src/plot.py +++ b/benchmark/src/plot.py @@ -112,7 +112,6 @@ def phases_figure_selected(df: pd.DataFrame) -> None: fig, ax = plt.subplots(figsize=(9, 6)) plot_df.plot.bar(stacked=True, color=PHASE_COLORS, width=0.8, ax=ax, legend=False, rot=0) - # total time above each bar for i, total in enumerate(means["total_s"]): ax.text(i, total, f"{total:.0f}s", ha="center", va="bottom", fontsize=8.5) diff --git a/rads/log-service/src/handlers/subjectAccessIngest.ts b/rads/log-service/src/handlers/subjectAccessIngest.ts index 28dd0191..a59b71e8 100644 --- a/rads/log-service/src/handlers/subjectAccessIngest.ts +++ b/rads/log-service/src/handlers/subjectAccessIngest.ts @@ -8,7 +8,7 @@ import { parseSubjectAccessBody, toItem } from "../lib/subjectAccess.js"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); const table = requiredEnv("SUBJECT_ACCESS_TABLE"); -// DynamoDB BatchWriteWriteItem accepts at most 25 items per request, so oversized batches are chunked. +// DynamoDB BatchWriteItem accepts at most 25 items per request, so oversized batches are chunked. const CHUNK = 25; const MAX_TRY = 4; diff --git a/rads/transparency-portal/src/components/ui/tabs.tsx b/rads/transparency-portal/src/components/ui/tabs.tsx index 439e37c5..274e9cfd 100644 --- a/rads/transparency-portal/src/components/ui/tabs.tsx +++ b/rads/transparency-portal/src/components/ui/tabs.tsx @@ -55,16 +55,13 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) { /algorithms) and its pin. -# Plain-TLS public domain (/attest, /refresh, /validate) baked into the EIF's run config - a different +# Plain-TLS public domain (/challenge, /attest, /refresh) baked into the EIF's run config - a different # domain and cert from the mTLS one above, so it gets its own pin. VERIFIER_HOST = $(VERIFIER_ATTEST_HOST) # pdm-service's plain-TLS domain (/records) also baked into the run config, pinned the same way. @@ -69,7 +69,7 @@ gen-client-cert: -keyout tls/client.key -out tls/client.crt \ -subj "/CN=registry-service" -# Build the docker image locally (arm64, matches the t4g.nano host). +# Build the docker image locally (arm64, matches the t4g.small host). image: sce-unit-base eif-build-base docker build --platform linux/arm64 -f Dockerfile -t $(IMAGE) ../../.. diff --git a/secure/csav/registry-service/eif.go b/secure/csav/registry-service/eif.go index 69df38d9..9d9e9eca 100644 --- a/secure/csav/registry-service/eif.go +++ b/secure/csav/registry-service/eif.go @@ -23,8 +23,6 @@ type pcrMeasurements struct { PCR2 string `json:"PCR2"` } -// AWS's own init binary (which we can't modify) requires /rootfs, /cmd (argv to exec after -// pivoting into /rootfs), and /env (fopen'd unconditionally; missing it crashes musl's fclose(NULL)). const sceEntrypoint = "/usr/local/bin/sce" // buildEIF measurements come as JSON on stdout - eif_build has no --pcrs_output flag. @@ -72,6 +70,8 @@ func buildEIF(ctx context.Context, rootfsDir, workDir string) (eifPath string, p return eifPath, result, nil } +// AWS's own init binary (which we can't modify) requires /rootfs, /cmd (argv to exec after +// pivoting into /rootfs), and /env (fopen'd unconditionally; missing it crashes musl's fclose(NULL)). func stageAppRamdisk(rootfsDir, stagingDir string) error { stagedRootfs := filepath.Join(stagingDir, "rootfs") if err := os.MkdirAll(filepath.Dir(stagedRootfs), 0o755); err != nil { diff --git a/secure/csav/registry-service/main.go b/secure/csav/registry-service/main.go index 79f9718e..40e03f87 100644 --- a/secure/csav/registry-service/main.go +++ b/secure/csav/registry-service/main.go @@ -71,7 +71,6 @@ func main() { } uploadDir := "/tmp/registry-service-uploads" - // 0o755: standard dir perms - MkdirAll requires a mode, no bare option. if err := os.MkdirAll(uploadDir, 0o755); err != nil { c.String(http.StatusInternalServerError, "could not create upload dir: %v", err) return diff --git a/secure/csav/registry-service/nsjail.cfg.tmpl b/secure/csav/registry-service/nsjail.cfg.tmpl index ee5ef798..6ac61d04 100644 --- a/secure/csav/registry-service/nsjail.cfg.tmpl +++ b/secure/csav/registry-service/nsjail.cfg.tmpl @@ -14,7 +14,7 @@ iface_no_lo: true mount_proc: true -# nsjail strips env vars by default; PATH here is sourced from the DC's own image (see pathFromEnv in build.go). +# nsjail strips env vars by default; PATH here is sourced from the DC's own image (see pathFromEnv in oci.go). envar: "PATH={{.PathEnv}}" envar: "RECORDS_PATH=/data/records.json" envar: "RESULT_PATH=/data/result.json" diff --git a/secure/csav/registry-service/rootfs.go b/secure/csav/registry-service/rootfs.go index 8901a4fa..f3fadfea 100644 --- a/secure/csav/registry-service/rootfs.go +++ b/secure/csav/registry-service/rootfs.go @@ -19,7 +19,8 @@ const ( caCertBundle = "/opt/assets/ca-certificates.crt" ) -// runConfig is baked into /etc/sce/run-config.json (see sce-unit/attest.go) and is part of the measured PCRs, so changing verifierHost or the pinned pubkey means rebuilding and re-registering the EIF. +// runConfig is baked into /etc/sce/run-config.json (see sce-unit/runconfig.go) and is part of the measured +// PCRs, so changing verifierHost or the pinned pubkey means rebuilding and re-registering the EIF. type runConfig struct { AlgorithmId string `json:"algorithmId"` VerifierHost string `json:"verifierHost"` diff --git a/secure/csav/registry-service/verifier.go b/secure/csav/registry-service/verifier.go index 3a43cf45..21114ff3 100644 --- a/secure/csav/registry-service/verifier.go +++ b/secure/csav/registry-service/verifier.go @@ -18,7 +18,7 @@ const ( verifierPinnedPubKeyEnv = "VERIFIER_PUBKEY_SHA256" ) -// verifierHost/verifierHostPubKeySHA256 pin the plain-TLS public domain (/attest, /refresh, /validate) baked +// verifierHost/verifierHostPubKeySHA256 pin the plain-TLS public domain (/challenge, /attest, /refresh) baked // into the EIF's run config - a different domain, and a different cert, from verifierURL below (mTLS, /algorithms). var ( verifierURL = os.Getenv("VERIFIER_URL") diff --git a/secure/eif-build/Dockerfile b/secure/eif-build/Dockerfile index 3930ea8d..0d5b9b76 100644 --- a/secure/eif-build/Dockerfile +++ b/secure/eif-build/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /src COPY Cargo.lock /src/Cargo.lock RUN cargo build --release --locked -p eif_build -# Version pinned to match the enclave host (sce/execution-service/ec2.go's UserData) - +# Version pinned to match the enclave host (sce/execution-service/userdata.sh.tmpl) - # a mismatch fails the boot handshake with AWS's E36/E39 "ready signal" errors. FROM amazonlinux:2023 AS blobs # Bootstrap ramdisk must be a bootable cpio (/init, /nsm.ko, /dev), not the raw init ELF. diff --git a/secure/log-service/src/handlers/subjectAccessIngest.ts b/secure/log-service/src/handlers/subjectAccessIngest.ts index 9ada148c..681646e5 100644 --- a/secure/log-service/src/handlers/subjectAccessIngest.ts +++ b/secure/log-service/src/handlers/subjectAccessIngest.ts @@ -9,7 +9,7 @@ import { parseSubjectAccessBody, toItem } from "../lib/subjectAccess.js"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); const table = requiredEnv("SUBJECT_ACCESS_TABLE"); -// DynamoDB BatchWriteWriteItem accepts at most 25 items per request, so oversized batches are chunked. +// DynamoDB BatchWriteItem accepts at most 25 items per request, so oversized batches are chunked. const CHUNK = 25; const MAX_TRY = 4; diff --git a/secure/sce-unit/entropy.go b/secure/sce-unit/entropy.go index 77fca29c..964e933a 100644 --- a/secure/sce-unit/entropy.go +++ b/secure/sce-unit/entropy.go @@ -14,8 +14,8 @@ import ( // A freshly booted Nitro Enclave has an unseeded kernel RNG - there is no /dev/random hardware source until the // nsm-hwrng registers, so crypto/rand's getrandom(2) intermittently blocks or fails on the first TLS handshakes // (attest, then the pdm fetch). seedEntropy pulls real entropy from the NSM and credits it to the kernel pool up -// front, making crypto deterministic. sce-unit is the enclave's PID 1 (CAP_SYS_ADMIN), so RNDADDENTROPY is -// permitted; outside an enclave (no /dev/nsm) this is a no-op. +// front, so those handshakes do not stall. sce-unit is the enclave's PID 1 (CAP_SYS_ADMIN), so RNDADDENTROPY is +// permitted; outside an enclave (no /dev/nsm) OpenDefaultSession fails and the run aborts. func seedEntropy() error { sess, err := nsm.OpenDefaultSession() if err != nil { diff --git a/secure/transparency-portal/src/components/ui/tabs.tsx b/secure/transparency-portal/src/components/ui/tabs.tsx index 439e37c5..274e9cfd 100644 --- a/secure/transparency-portal/src/components/ui/tabs.tsx +++ b/secure/transparency-portal/src/components/ui/tabs.tsx @@ -55,16 +55,13 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {