@cubocicloide/stack-react-fastapi 13.1.0 → 13.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubocicloide/stack-react-fastapi",
3
- "version": "13.1.0",
3
+ "version": "13.3.0",
4
4
  "description": "React (Vite) + FastAPI stack plugin for the dude CLI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,13 +9,20 @@ WORKDIR /app
9
9
 
10
10
  RUN pip install --no-cache-dir uv
11
11
 
12
- COPY pyproject.toml .
12
+ # Run as an unprivileged user (trivy DS002). The user is created *before* the
13
+ # virtualenv is built so every layer is written with the right ownership — a
14
+ # trailing `chown -R /app` would instead duplicate the whole .venv into an
15
+ # extra layer.
16
+ RUN useradd -m -u 1000 appuser && chown appuser:appuser /app
17
+ USER appuser
18
+
19
+ COPY --chown=appuser:appuser pyproject.toml .
13
20
  RUN uv sync --no-cache --no-dev
14
21
 
15
- COPY app ./app
22
+ COPY --chown=appuser:appuser app ./app
16
23
  {{#if withPostgres}}
17
- COPY alembic ./alembic
18
- COPY alembic.ini ./alembic.ini
24
+ COPY --chown=appuser:appuser alembic ./alembic
25
+ COPY --chown=appuser:appuser alembic.ini ./alembic.ini
19
26
  {{/if}}
20
27
 
21
28
  EXPOSE 8000
@@ -94,6 +94,35 @@ dude iac ship --env staging
94
94
  > `dude iac deploy --env staging --tag <sha>` (use the tag from
95
95
  > `dude iac status --env dev`).
96
96
 
97
+ ## Image tags
98
+
99
+ The ECR repositories are **immutable**: a tag is written once and can never be
100
+ overwritten. That is what makes "promote the image from dev to staging" mean
101
+ something — a tag names one exact set of bytes, for as long as it exists.
102
+
103
+ So `dude iac build/push/ship` derive the tag from your git state rather than
104
+ letting you overwrite one:
105
+
106
+ | Working tree | Tag |
107
+ |--------------|-----|
108
+ | clean | `<git-short-sha>` |
109
+ | uncommitted changes | `<git-short-sha>-dirty-<hash-of-the-diff>` |
110
+
111
+ The `-dirty-<hash>` part is why iterating on a branch works: every edit changes
112
+ the digest, so every `dude iac ship` gets a fresh tag. Re-shipping a state you
113
+ have already pushed — same commit, same edits — is the one case that stops, and
114
+ it stops *before* building, with the three options spelled out:
115
+
116
+ ```
117
+ ✗ <repo>:<tag> already exists, and the repository is immutable.
118
+ • commit your work and re-run — a new SHA gives a new tag;
119
+ • push under a different tag: dude iac push --env dev --tag <tag>.1
120
+ • or deploy what is already there: dude iac deploy --env dev --tag <tag>
121
+ ```
122
+
123
+ That last one is usually what you want: the image is already in ECR, so there is
124
+ nothing to rebuild.
125
+
97
126
  ## HTTPS on a custom domain *(optional)*
98
127
 
99
128
  Set these in `iac/terraform/environments/dev/terraform.tfvars` (the Route53
@@ -1,5 +1,5 @@
1
1
  # Production image for the frontend: build the Vite app, serve the static
2
- # bundle with nginx. Used by the Helm deployment (port 80). The dev Dockerfile
2
+ # bundle with nginx. Used by the Helm deployment (port 8080). The dev Dockerfile
3
3
  # (Vite dev server) is kept for `dude up`.
4
4
  #
5
5
  # VITE_* values are baked in at build time — pass them as build args:
@@ -21,8 +21,12 @@ ENV VITE_REACT_QUERY_DEVTOOLS=$VITE_REACT_QUERY_DEVTOOLS
21
21
  COPY . .
22
22
  RUN pnpm build
23
23
 
24
- FROM nginx:1.27-alpine
24
+ # nginx-unprivileged is the stock nginx image rebuilt to run as UID 101 with no
25
+ # root master process (trivy DS002). Because it cannot bind a privileged port,
26
+ # it listens on 8080 — see nginx.conf and `frontend.port` in the Helm values.
27
+ FROM nginxinc/nginx-unprivileged:1.27-alpine
25
28
  COPY --from=build /app/dist /usr/share/nginx/html
26
29
  COPY nginx.conf /etc/nginx/conf.d/default.conf
27
- EXPOSE 80
30
+ USER nginx
31
+ EXPOSE 8080
28
32
  CMD ["nginx", "-g", "daemon off;"]
@@ -2,7 +2,8 @@
2
2
  # (path-based), so nginx only needs to serve the static bundle and fall back to
3
3
  # index.html for client-side routes.
4
4
  server {
5
- listen 80;
5
+ # 8080, not 80: the image runs unprivileged and cannot bind a port < 1024.
6
+ listen 8080;
6
7
  server_name _;
7
8
  root /usr/share/nginx/html;
8
9
  index index.html;
@@ -34,8 +34,9 @@ backend:
34
34
 
35
35
  frontend:
36
36
  replicas: 2
37
- ## nginx serving the production build (see frontend/Dockerfile.prod)
38
- port: 80
37
+ ## nginx serving the production build (see frontend/Dockerfile.prod). 8080
38
+ ## because that image runs unprivileged and cannot bind a port below 1024.
39
+ port: 8080
39
40
  resources:
40
41
  requests:
41
42
  cpu: 50m
@@ -49,12 +49,32 @@ resource "aws_s3_bucket_versioning" "state" {
49
49
  }
50
50
  }
51
51
 
52
+ # Terraform state records every attribute of every resource — including the
53
+ # generated RDS password — so it gets a customer managed key rather than the
54
+ # AWS-owned S3 key (AVD-AWS-0132). The practical difference is control: rotation
55
+ # you can schedule, a key policy you can audit, and the ability to revoke access
56
+ # to the state without touching the bucket.
57
+ resource "aws_kms_key" "state" {
58
+ description = "${var.project_name} — Terraform state encryption"
59
+ enable_key_rotation = true
60
+ deletion_window_in_days = 7
61
+ }
62
+
63
+ resource "aws_kms_alias" "state" {
64
+ name = "alias/${var.project_name}-tfstate"
65
+ target_key_id = aws_kms_key.state.key_id
66
+ }
67
+
52
68
  resource "aws_s3_bucket_server_side_encryption_configuration" "state" {
53
69
  bucket = aws_s3_bucket.state.id
54
70
  rule {
55
71
  apply_server_side_encryption_by_default {
56
- sse_algorithm = "AES256"
72
+ sse_algorithm = "aws:kms"
73
+ kms_master_key_id = aws_kms_key.state.arn
57
74
  }
75
+ # One data key per bucket rather than one per object: same protection, and
76
+ # it keeps the (billed) KMS request count flat as the state grows.
77
+ bucket_key_enabled = true
58
78
  }
59
79
  }
60
80
 
@@ -82,7 +102,7 @@ resource "aws_dynamodb_table" "lock" {
82
102
  # only here, with the rest of the shared backend.
83
103
  resource "aws_ecr_repository" "backend" {
84
104
  name = "${var.project_name}-backend"
85
- image_tag_mutability = "MUTABLE"
105
+ image_tag_mutability = "IMMUTABLE"
86
106
  force_delete = true
87
107
 
88
108
  image_scanning_configuration {
@@ -92,7 +112,7 @@ resource "aws_ecr_repository" "backend" {
92
112
 
93
113
  resource "aws_ecr_repository" "frontend" {
94
114
  name = "${var.project_name}-frontend"
95
- image_tag_mutability = "MUTABLE"
115
+ image_tag_mutability = "IMMUTABLE"
96
116
  force_delete = true
97
117
 
98
118
  image_scanning_configuration {
@@ -56,6 +56,13 @@ module "eks" {
56
56
  min_size = var.node_min_size
57
57
  max_size = var.node_max_size
58
58
  desired_size = var.node_desired_size
59
+
60
+ # IMDSv2 is not configured here on purpose: the module already defaults
61
+ # `metadata_options` to { http_endpoint = "enabled", http_tokens =
62
+ # "required", http_put_response_hop_limit = 2 }. That variable is
63
+ # replaced wholesale rather than merged, so overriding it with just
64
+ # `http_tokens` would silently drop the hop limit to the AWS default of
65
+ # 1 and cut pods off from the instance metadata endpoint.
59
66
  }
60
67
  }
61
68
  }
@@ -255,11 +262,13 @@ resource "aws_security_group" "rds" {
255
262
  cidr_blocks = [var.vpc_cidr]
256
263
  }
257
264
 
265
+ # Restrict egress to VPC only (security best practice)
258
266
  egress {
267
+ description = "Allow outbound to VPC for responses"
259
268
  from_port = 0
260
269
  to_port = 0
261
270
  protocol = "-1"
262
- cidr_blocks = ["0.0.0.0/0"]
271
+ cidr_blocks = [var.vpc_cidr]
263
272
  }
264
273
 
265
274
  lifecycle {
@@ -134,7 +134,20 @@ using the `react-fastapi` stack:
134
134
  | `dude api review` | Validate `frontend/src/openapi/` against the saved spec |
135
135
 
136
136
  **Workflow**: always run `dude api sync` after changing backend routes, then commit
137
- the updated `frontend/src/openapi/` alongside the route change.
137
+ the updated `frontend/src/openapi/` alongside the route change. The reference is
138
+ served at http://localhost:8000/api/docs (Scalar).
139
+
140
+ **Documenting a route** — the schema only carries what the code declares:
141
+
142
+ - Every route gets a `tags` entry (on the `APIRouter`), an imperative `summary`
143
+ (≤ 6 words) and a `description` that says something the schema does not already
144
+ show — preconditions, side effects, who may call it, which error a wrong call
145
+ returns.
146
+ - Every tag used must exist in `API_TAGS` in `backend/app/core/api_docs.py`, or the
147
+ operation lands ungrouped at the bottom of the sidebar. `API_TAGS` order **is**
148
+ the sidebar order.
149
+ - Cross-cutting prose (auth header, conventions, the domain lifecycle) belongs in
150
+ `API_DESCRIPTION` in the same file, not repeated per route.
138
151
 
139
152
  ### Testing
140
153
 
@@ -71,8 +71,8 @@ Once the containers are up, open the URLs below.
71
71
  |---------|-----|-------|
72
72
  | **Frontend** | http://localhost:5173 | React + Vite — HMR active |
73
73
  | **API** | http://localhost:8000 | FastAPI |
74
- | **Swagger UI** | http://localhost:8000/api/docs | Interactive API explorer |
75
- | **ReDoc** | http://localhost:8000/api/redoc | API reference docs |
74
+ | **API reference** | http://localhost:8000/api/docs | Interactive reference (Scalar) — narrative in `backend/app/core/api_docs.py` |
75
+ | **OpenAPI schema** | http://localhost:8000/api/openapi.json | Raw schema (JSON) |
76
76
  | **Health** | http://localhost:8000/api/health | JSON health check |
77
77
  {{#if withCelery}}
78
78
  | **Flower** | http://localhost:5555 | Celery task monitor |
@@ -0,0 +1,182 @@
1
+ """Narrative, sidebar structure and the reference page for the public API.
2
+
3
+ ``API_DESCRIPTION`` becomes ``info.description`` in the OpenAPI schema and renders
4
+ as the landing page of the reference at ``/api/docs``. ``API_TAGS`` is the
5
+ sidebar: its order is the sidebar order, and every tag used by a router must
6
+ appear here or the operation lands ungrouped at the bottom. ``scalar_html``
7
+ renders the reference page itself.
8
+
9
+ All three are wired up in ``app/main.py``.
10
+
11
+ This file is where the reference stops being generated and starts being written.
12
+ Edit it as the API grows — the sections marked **TODO** describe your product,
13
+ not the scaffold.
14
+ """
15
+
16
+ API_DESCRIPTION = """
17
+ The **{{projectName}}** HTTP API. It is consumed by the {{projectName}} web frontend and by any
18
+ service you authorise. Every response is JSON; every path below is relative to
19
+ `/api`.
20
+
21
+ <!-- TODO: replace this paragraph with what the API actually is — the domain in
22
+ plain words, who calls it, and what a caller can accomplish with it. If it is
23
+ internal-only, say so here rather than making integrators discover it from a 401. -->
24
+
25
+ ## Authentication
26
+
27
+ **The scaffold ships no authentication.** Every endpoint below is open to anyone
28
+ who can reach the process. That is fine behind `docker compose` on your laptop and
29
+ unacceptable anywhere else.
30
+
31
+ <!-- TODO: add a scheme before this API leaves your machine. Declare a FastAPI
32
+ security dependency (e.g. `fastapi.security.HTTPBearer`), apply it to the routers
33
+ in `app/main.py`, then document the exact header here, verbatim:
34
+
35
+ ```
36
+ Authorization: Bearer <access-token>
37
+ ```
38
+
39
+ Spell out how a caller obtains the credential, how long it lives, and how it is
40
+ refreshed. Prefix mistakes are the most common integration failure — write the
41
+ header out, do not paraphrase it. Then uncomment `preferredSecurityScheme` in
42
+ `scalar_html` below and point it at the matching key from
43
+ `components.securitySchemes`. -->
44
+
45
+ ## Base URLs
46
+
47
+ | Environment | Base URL |
48
+ | --- | --- |
49
+ | Local development | `http://localhost:8000` |
50
+
51
+ <!-- TODO: add the deployed environments and mirror them in the `servers` list in
52
+ `app/main.py` so the **Test Request** panel can target them. -->
53
+
54
+ ## Conventions
55
+
56
+ - **No trailing slashes.** Paths are registered as `/api/users`, not `/api/users/`.
57
+ A trailing slash returns `307` and clients that drop the body on redirect fail
58
+ confusingly.
59
+ - **List endpoints return bare arrays**, not a pagination envelope, and they are
60
+ unbounded — every row comes back in one response. Add pagination before any
61
+ collection can grow.
62
+ - **Timestamps** — ISO-8601 with an offset, always UTC (`2026-01-31T09:15:00Z`).
63
+ - **IDs** — sequential integers, not UUIDs. Do not assume they are unguessable.
64
+ - **Errors** — two distinct body shapes:
65
+ - raised failures (`HTTPException`, e.g. 404): `{"detail": "User not found"}`
66
+ - request validation failures (**422**, produced by FastAPI itself before your
67
+ code runs): `{"detail": [{"loc": ["path", "id"], "msg": "…", "type": "…"}]}`.
68
+ Note the status code — FastAPI answers malformed input with `422`, not `400`.
69
+
70
+ ## Lifecycle
71
+
72
+ <!-- TODO: this section carries the most weight in the whole reference, and the
73
+ scaffold cannot write it for you. Describe the state machine a caller must
74
+ respect: which state an object starts in, what each transition requires as a
75
+ precondition, what locks afterwards, and which status code a premature call
76
+ gets. Per-endpoint docs cannot express this; leaving it out is what makes
77
+ integrators guess. Delete this section only if the domain genuinely has no
78
+ stateful objects. -->
79
+
80
+ ## Status
81
+
82
+ - The API is **unversioned**. Breaking changes ship without a path bump — pin
83
+ nothing, read the changelog.
84
+ - `GET /api/health` is a liveness probe, not a status page: it reports that the
85
+ process is up, not that the database is.
86
+ - No authentication, no pagination, no rate limiting, and no webhooks yet.
87
+ """.strip()
88
+
89
+
90
+ API_TAGS = [
91
+ {
92
+ "name": "Health",
93
+ "description": "Liveness probe. Used by container health checks and the frontend boot sequence.",
94
+ },
95
+ {{#if withPostgres}}
96
+ {
97
+ "name": "Users",
98
+ "description": "The accounts this API knows about. Read-only in the scaffold — writes belong in `app/queries/users.py`.",
99
+ },
100
+ {{/if}}
101
+ ]
102
+
103
+
104
+ # Plain placeholders (not an f-string / str.format) so the CSS and JS braces below
105
+ # stay readable and unescaped.
106
+ _SCALAR_PAGE = """<!doctype html>
107
+ <html lang="en">
108
+ <head>
109
+ <meta charset="utf-8" />
110
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
111
+ <title>__TITLE__ API reference</title>
112
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='12' fill='%231677ff'/%3E%3C/svg%3E" />
113
+ <style>
114
+ html, body { margin: 0; }
115
+ :root {
116
+ --scalar-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
117
+ --scalar-font-code: ui-monospace, SFMono-Regular, Menlo, monospace;
118
+ }
119
+ /* Brand accent — matches the frontend's antd primary colour. */
120
+ .light-mode { --scalar-color-accent: #1677ff; }
121
+ .dark-mode { --scalar-color-accent: #4096ff; }
122
+
123
+ /* Brand bar. Delete this block and the <header> below together if you'd
124
+ rather have Scalar's own header on its own. */
125
+ .brandbar {
126
+ position: sticky; top: 0; z-index: 1000;
127
+ display: flex; align-items: center; gap: 0.75rem;
128
+ height: 56px; padding: 0 1.25rem;
129
+ background: #1677ff;
130
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
131
+ }
132
+ .brandbar .name { color: #fff; font: 600 1rem/1 system-ui, -apple-system, sans-serif; }
133
+ .brandbar .spacer { flex: 1; }
134
+ .brandbar .tag {
135
+ color: #fff; opacity: 0.92;
136
+ font: 600 0.78rem/1 system-ui, -apple-system, sans-serif;
137
+ letter-spacing: 0.06em; text-transform: uppercase;
138
+ }
139
+ </style>
140
+ </head>
141
+ <body>
142
+ <header class="brandbar">
143
+ <span class="name">__TITLE__</span>
144
+ <span class="spacer"></span>
145
+ <span class="tag">API reference</span>
146
+ </header>
147
+ <div id="app"></div>
148
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
149
+ <script>
150
+ Scalar.createApiReference('#app', {
151
+ url: '__OPENAPI_URL__',
152
+ theme: 'default',
153
+ layout: 'modern',
154
+ hideDownloadButton: true,
155
+ showDeveloperTools: 'never',
156
+ persistAuth: true,
157
+ withDefaultFonts: false,
158
+ metaData: {
159
+ title: '__TITLE__ API reference',
160
+ description: 'HTTP API reference for __TITLE__.',
161
+ },
162
+ // Once you add a security scheme, name it here so the Authentication
163
+ // panel opens on it instead of "No authentication selected". The value
164
+ // must match a key under components.securitySchemes in the schema.
165
+ // authentication: { preferredSecurityScheme: 'HTTPBearer' },
166
+ customCss: `
167
+ :root {
168
+ /* Room for the brand bar so Scalar still fits the viewport. Drop
169
+ this line together with the <header> if you remove the bar. */
170
+ --scalar-custom-header-height: 56px;
171
+ }
172
+ a[href*="scalar.com"] { display: none !important; }
173
+ `,
174
+ })
175
+ </script>
176
+ </body>
177
+ </html>"""
178
+
179
+
180
+ def scalar_html(title: str, openapi_url: str) -> str:
181
+ """Render the API reference page (Scalar, loaded from a CDN)."""
182
+ return _SCALAR_PAGE.replace("__TITLE__", title).replace("__OPENAPI_URL__", openapi_url)
@@ -2,7 +2,10 @@
2
2
 
3
3
  from fastapi import APIRouter, FastAPI
4
4
  from fastapi.middleware.cors import CORSMiddleware
5
+ from fastapi.responses import HTMLResponse
5
6
 
7
+ from app.core.api_docs import API_DESCRIPTION, API_TAGS, scalar_html
8
+ from app.core.config import settings
6
9
  from app.routers import (
7
10
  health,
8
11
  {{#if withPostgres}}
@@ -15,10 +18,19 @@ from app.routers import (
15
18
  # the ALB Ingress (which routes /api → backend, everything else → frontend). This
16
19
  # keeps a single backend prefix and works identically in local dev (the Vite
17
20
  # proxy forwards /api) and in the cluster.
21
+ #
22
+ # The built-in Swagger UI and ReDoc are off: /api/docs is the one reference, and
23
+ # it renders the narrative from app/core/api_docs.py.
18
24
  app = FastAPI(
19
- title="{{projectName}} backend",
20
- docs_url="/api/docs",
21
- redoc_url="/api/redoc",
25
+ title="{{projectName}} API",
26
+ description=API_DESCRIPTION,
27
+ version="1.0.0",
28
+ openapi_tags=API_TAGS,
29
+ # Add deployed environments here so the reference's "Test Request" panel can
30
+ # target them.
31
+ servers=[{"url": "http://localhost:8000", "description": "Local development"}],
32
+ docs_url=None,
33
+ redoc_url=None,
22
34
  openapi_url="/api/openapi.json",
23
35
  )
24
36
 
@@ -30,6 +42,13 @@ app.add_middleware(
30
42
  allow_headers=["*"],
31
43
  )
32
44
 
45
+
46
+ @app.get("/api/docs", include_in_schema=False)
47
+ async def get_api_docs() -> HTMLResponse:
48
+ """Serve the API reference (Scalar)."""
49
+ return HTMLResponse(scalar_html(settings.APP_TITLE, "/api/openapi.json"))
50
+
51
+
33
52
  api_router = APIRouter(prefix="/api")
34
53
 
35
54
  api_router.include_router(health.router)
@@ -4,10 +4,18 @@ from fastapi import APIRouter
4
4
 
5
5
  from app.schemas.health import HealthResponse
6
6
 
7
- router = APIRouter()
7
+ router = APIRouter(tags=["Health"])
8
8
 
9
9
 
10
- @router.get("/health")
10
+ @router.get(
11
+ "/health",
12
+ summary="Check service health",
13
+ description=(
14
+ 'Returns `{"status": "ok"}` while the process is accepting requests. This '
15
+ "is a liveness probe, not a status page — it does not test the database, "
16
+ "the cache or any downstream service."
17
+ ),
18
+ )
11
19
  async def get_health() -> HealthResponse:
12
20
  """Health-check endpoint."""
13
21
  return HealthResponse(status="ok")
@@ -36,5 +36,9 @@ line-length = 100
36
36
  [tool.ruff.lint]
37
37
  select = ["E", "F", "I", "N", "UP", "B", "S", "RUF"]
38
38
 
39
+ [tool.ruff.lint.per-file-ignores]
40
+ # Prose and an embedded HTML document — line length is not a useful rule there.
41
+ "app/core/api_docs.py" = ["E501"]
42
+
39
43
  [tool.mypy]
40
44
  strict = true
@@ -61,8 +61,8 @@ Once the stack is up, open these URLs:
61
61
  |---------|-----|-------|
62
62
  | **Frontend** | http://localhost:5173 | React + Vite — HMR active |
63
63
  | **API** | http://localhost:8000 | FastAPI |
64
- | **Swagger UI** | http://localhost:8000/api/docs | Interactive API explorer |
65
- | **ReDoc** | http://localhost:8000/api/redoc | API reference docs |
64
+ | **API reference** | http://localhost:8000/api/docs | Interactive reference (Scalar) |
65
+ | **OpenAPI schema** | http://localhost:8000/api/openapi.json | Raw schema (JSON) |
66
66
  | **Health** | http://localhost:8000/api/health | JSON health check |
67
67
  {{#if withCelery}}| **Flower** | http://localhost:5555 | Celery task monitor |
68
68
  {{/if}}
@@ -237,6 +237,25 @@ git add security/baseline.json && git commit -m "chore(security): update baselin
237
237
  `security/baseline.json` must be committed — it is the source of truth for
238
238
  accepted findings. Subsequent scans only flag findings that are **not** in the
239
239
  baseline.
240
+
241
+ **Baseline or ignore file?** Two mechanisms, deliberately different:
242
+
243
+ | | Use for | Behaviour |
244
+ |-|---------|-----------|
245
+ | `security/baseline.json` | findings you have triaged and mean to address | fingerprinted; a finding reappears as *new* if its location changes, and `dude security verify` prunes it once fixed |
246
+ | `security/.trivyignore.yaml` | findings that are correct **by design** and will never be fixed | matched by rule id + path; permanently silent, with a `statement:` recording why |
247
+
248
+ The scaffold ships one ignore entry: **DS002** (container runs as root) on
249
+ `backend/Dockerfile` and `frontend/Dockerfile`. Those are the development images
250
+ that `dude up` builds — they never leave your machine, they bind-mount your
251
+ source tree, and pinning them to a non-root UID breaks writes back into it (the
252
+ alembic revision `dude db makemigration` generates, for instance) on any host
253
+ whose UID is not 1000. The images that actually ship — `Dockerfile.prod` for
254
+ both backend and frontend — do run unprivileged.
255
+
256
+ Trivy is also pointed away from `.terraform/`: once `dude iac init` has run,
257
+ that directory holds the vendored source of every third-party Terraform module,
258
+ and its misconfigurations are not yours to fix.
240
259
  {{#if withIac}}
241
260
 
242
261
  ---
@@ -73,7 +73,8 @@ dude docs # → http://localhost:8001
73
73
  |----------|-----|
74
74
  | Frontend (dev) | <http://localhost:5173> |
75
75
  | Backend API | <http://localhost:8000> |
76
- | Swagger UI | <http://localhost:8000/api/docs> |
76
+ | API reference (Scalar) | <http://localhost:8000/api/docs> |
77
+ | OpenAPI schema | <http://localhost:8000/api/openapi.json> |
77
78
  | API health | <http://localhost:8000/api/health> |
78
79
  {{#if withCelery}}
79
80
  | Flower | <http://localhost:5555> |
@@ -1,12 +1,14 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
- title: {{projectName}} backend
4
- version: 0.1.0
3
+ title: {{projectName}} API
4
+ version: 1.0.0
5
5
  paths:
6
6
  /api/health:
7
7
  get:
8
- summary: Get Health
9
- description: Health-check endpoint.
8
+ tags:
9
+ - Health
10
+ summary: Check service health
11
+ description: 'Returns `{"status": "ok"}` while the process is accepting requests.'
10
12
  operationId: get_health_api_health_get
11
13
  responses:
12
14
  "200":
@@ -90,10 +90,10 @@ export default function HomePage() {
90
90
  <Col xs={24} md={8}>
91
91
  <Card title={<><CodeOutlined /> Quick links</>} style={{ height: '100%' }}>
92
92
  <Space wrap size="middle">
93
- <Link href="/api/docs" target="_blank">
93
+ <Link href="http://localhost:8000/api/docs" target="_blank">
94
94
  API docs (Swagger)
95
95
  </Link>
96
- <Link href="/api/redoc" target="_blank">
96
+ <Link href="http://localhost:8000/api/redoc" target="_blank">
97
97
  ReDoc
98
98
  </Link>
99
99
  <Link href="http://localhost:8001" target="_blank">
@@ -0,0 +1,49 @@
1
+ # Trivy ignore file — accepted findings, with the reason recorded next to each.
2
+ #
3
+ # This is for findings that are *by design* and will never be "fixed", so they
4
+ # would otherwise reappear on every scan. Findings you have merely triaged and
5
+ # intend to address belong in the baseline instead:
6
+ #
7
+ # dude security accept # absorb current findings
8
+ # dude security verify --rule-id <id> # confirm a fix, prune from the baseline
9
+ #
10
+ # Wired in by `dude security scan` via --ignorefile; delete this file and every
11
+ # entry below becomes a live finding again.
12
+
13
+ vulnerabilities:
14
+ - id: GHSA-qwww-vcr4-c8h2
15
+ paths:
16
+ - frontend/package-lock.json
17
+ - frontend/pnpm-lock.yaml
18
+ # Revisit rather than forget: after this date trivy reports it again.
19
+ expired_at: 2027-02-01
20
+ statement: >
21
+ Not reachable in this application. The advisory is a CSRF bypass in React
22
+ Router's RSC (React Server Components) mode; this frontend is a Vite SPA
23
+ doing client-side routing with react-router-dom, and never runs RSC. The
24
+ only published fix is react-router 8.3.0 — a major version with breaking
25
+ routing changes — so upgrading is a deliberate migration, not a patch.
26
+ Re-check when moving to react-router 8 for any other reason.
27
+
28
+ misconfigurations:
29
+ - id: DS002
30
+ paths:
31
+ - backend/Dockerfile
32
+ - frontend/Dockerfile
33
+ statement: >
34
+ Development images only. They are built by `dude up` and never leave the
35
+ developer's machine — Kubernetes runs backend/Dockerfile.prod and
36
+ frontend/Dockerfile.prod, both of which do run as an unprivileged user.
37
+ Forcing a non-root UID here breaks writes to the bind-mounted source tree
38
+ (`dude db makemigration` writing alembic/versions/, for one) on any host
39
+ whose UID is not 1000.
40
+
41
+ - id: DS002
42
+ paths:
43
+ - iac/runner/Dockerfile
44
+ statement: >
45
+ Local tooling container, not a workload. `dude iac *` runs terraform,
46
+ kubectl, helm and k9s inside it with your own ~/.aws and ~/.kube mounted
47
+ in; it is started on demand, never deployed, and never exposed. Running
48
+ as root is what lets those tools write to the mounted credential caches
49
+ whatever your host UID happens to be.
@@ -9,11 +9,19 @@ from app.core.database import get_db
9
9
  from app.models.user import User
10
10
  from app.queries.users import UsersQueries
11
11
 
12
- router = APIRouter(tags=["users"])
12
+ router = APIRouter(tags=["Users"])
13
13
  _users = UsersQueries()
14
14
 
15
15
 
16
- @router.get("/users", response_model=list[User])
16
+ @router.get(
17
+ "/users",
18
+ response_model=list[User],
19
+ summary="List users",
20
+ description=(
21
+ "Returns every user as a bare array — there is no pagination envelope and "
22
+ "no result cap. Add pagination before this collection can grow."
23
+ ),
24
+ )
17
25
  def get_users(db: Session = Depends(get_db)) -> Sequence[User]:
18
26
  """Return all users."""
19
27
  return _users.get_all(db)