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
22 changes: 2 additions & 20 deletions benchmark/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# --- Core Settings ---

# Set line length to 120 characters
line-length = 120

# Target Python 3.12
target-version = "py312"

src = ["src"]
Expand Down Expand Up @@ -35,29 +30,22 @@ exclude = [
"cdk.out",
]

# --- Formatter Configuration ---
[format]
quote-style = "double"
indent-style = "space"
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",
Expand Down Expand Up @@ -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" = [
Expand Down
1 change: 0 additions & 1 deletion benchmark/src/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion rads/log-service/src/handlers/subjectAccessIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 0 additions & 8 deletions rads/transparency-portal/src/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,34 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
<TabsPrimitive.Tab
data-slot="tabs-trigger"
className={cn(
// Layout
"relative inline-flex flex-1 items-center justify-center gap-1.5",
"h-[calc(100%-1px)] px-1.5 py-0.5 rounded-md",
"group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start",

// Base appearance
"border border-transparent text-sm font-medium whitespace-nowrap",
"text-foreground/60 transition-all",

// Interaction
"hover:text-foreground",
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
"focus-visible:outline-1 focus-visible:outline-ring",
"disabled:pointer-events-none disabled:opacity-50",
"aria-disabled:pointer-events-none aria-disabled:opacity-50",
"has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1",

// Icon sizing
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",

// Dark mode
"dark:text-muted-foreground dark:hover:text-foreground",

// Active state
"data-active:bg-background data-active:text-foreground",
"dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
"group-data-[variant=default]/tabs-list:data-active:shadow-sm",
"group-data-[variant=line]/tabs-list:data-active:shadow-none",

// Line variant
"group-data-[variant=line]/tabs-list:bg-transparent",
"group-data-[variant=line]/tabs-list:data-active:bg-transparent",
"dark:group-data-[variant=line]/tabs-list:data-active:border-transparent",
"dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",

// Active indicator
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity",
"group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px]",
"group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0",
Expand Down
4 changes: 2 additions & 2 deletions secure/csav/registry-service/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CSAV_ROLE_ARN = $(shell aws cloudformation describe-stacks --stack-name $(STACK_
KMS_SERVICE_ROLE_ARN = $(shell aws cloudformation describe-stacks --stack-name secure-rads-kms-service-dev --region $(REGION) \
--query "Stacks[0].Outputs[?OutputKey=='KmsServiceRoleArn'].OutputValue" --output text)
# mTLS domain (registerPCRs -> /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.
Expand Down Expand Up @@ -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) ../../..

Expand Down
4 changes: 2 additions & 2 deletions secure/csav/registry-service/eif.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion secure/csav/registry-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion secure/csav/registry-service/nsjail.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion secure/csav/registry-service/rootfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion secure/csav/registry-service/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion secure/eif-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion secure/log-service/src/handlers/subjectAccessIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions secure/sce-unit/entropy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions secure/transparency-portal/src/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,34 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
<TabsPrimitive.Tab
data-slot="tabs-trigger"
className={cn(
// Layout
"relative inline-flex flex-1 items-center justify-center gap-1.5",
"h-[calc(100%-1px)] px-1.5 py-0.5 rounded-md",
"group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start",

// Base appearance
"border border-transparent text-sm font-medium whitespace-nowrap",
"text-foreground/60 transition-all",

// Interaction
"hover:text-foreground",
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
"focus-visible:outline-1 focus-visible:outline-ring",
"disabled:pointer-events-none disabled:opacity-50",
"aria-disabled:pointer-events-none aria-disabled:opacity-50",
"has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1",

// Icon sizing
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",

// Dark mode
"dark:text-muted-foreground dark:hover:text-foreground",

// Active state
"data-active:bg-background data-active:text-foreground",
"dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
"group-data-[variant=default]/tabs-list:data-active:shadow-sm",
"group-data-[variant=line]/tabs-list:data-active:shadow-none",

// Line variant
"group-data-[variant=line]/tabs-list:bg-transparent",
"group-data-[variant=line]/tabs-list:data-active:bg-transparent",
"dark:group-data-[variant=line]/tabs-list:data-active:border-transparent",
"dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",

// Active indicator
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity",
"group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px]",
"group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0",
Expand Down
2 changes: 1 addition & 1 deletion secure/verifier-service/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ resources:
ApiId: !Ref HttpApi
Stage: !Ref HttpApiStage

# Separate API from the mTLS one above - /attest, /refresh, /.well-known/jwks.json are plain server-auth
# Separate API from the mTLS one above - /challenge, /attest, /refresh, /.well-known/jwks.json are plain server-auth
# TLS, pinned to this domain's leaf pubkey by callers instead (sce-unit has no client cert to present).
PublicHttpApi:
Type: AWS::ApiGatewayV2::Api
Expand Down
5 changes: 3 additions & 2 deletions secure/verifier-service/src/lib/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({}));
const tableName = requiredEnv("ATTESTATION_SESSION_TABLE");

// Access tokens are self-contained ML-DSA-87 JWTs that downstream services verify locally against the public
// JWKS endpoint - no /validate round-trip. They are short-lived so a revoked session stops working within
// minutes. Refresh tokens stay opaque and stored hashed: the DB row is what makes revocation possible.
// JWKS endpoint - no /validate round-trip. They are short-lived (2 hours) so a revoked session stops working
// once its access token expires. Refresh tokens stay opaque and stored hashed: the DB row is what makes
// revocation possible.
const ACCESS_TOKEN_TTL_SECONDS = 2 * 60 * 60;
// The refresh token must outlive the access token, otherwise sce-unit's pre-expiry refresh can never succeed.
const REFRESH_TOKEN_TTL_SECONDS = 4 * 60 * 60;
Expand Down
2 changes: 0 additions & 2 deletions seeding/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ function pii(age: number) {
};
}

// Each generator returns one record's `data` object.

function healthData() {
const age = faker.number.int({ min: 18, max: 90 });
const sex = faker.helpers.arrayElement(["male", "female"] as const);
Expand Down
Loading