·
Last changedVersion:
This version passed the hardening gate. Hardening applied 16 targeted changes and preserved all other text. Classified findings before hardening: 1. Classified findings closed: 0. Classified findings remaining: 1. Unclassified scanner findings remaining: 0. Review findings closed: 20. Review findings remaining: 4.
1
1
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Supply Chain & Install-Time Trust | — | Medium | Open |
1 finding
Azure Static Web Apps (SWA) hosts static frontends with optional serverless API backends. The SWA CLI (swa) provides local development emulation and deployment capabilities.
Key features:
Config files:
swa-cli.config.json - CLI settings, created by swa init (never create manually)staticwebapp.config.json - Runtime config (routes, auth, headers, API runtime) - can be created manuallyVerify: npx swa --version
Pin an exact CLI version in the project's package file, commit the lockfile, and run npx only after this local install so it resolves the pinned package. Pin the Azure Functions package the same way in the API folder.
IMPORTANT: Always use swa init to create configuration files. Never manually create swa-cli.config.json.
swa init - Required first step - auto-detects framework and creates swa-cli.config.jsonswa start - Run local emulator at http://localhost:4280swa login - Authenticate with Azureswa deploy - Deploy to Azure, after confirming the app name, subscription and target environment with the user. Start with a dry run or a preview deploy.swa-cli.config.json - Created by swa init, do not create manually:
swa init for interactive setup with framework detectionswa init --yes to accept auto-detected defaults in trusted repositories onlyExample of generated config (for reference only):
staticwebapp.config.json (in app source or output folder) - This file CAN be created manually for runtime configuration:
Routes not listed stay public by default. Give admin and other sensitive paths their own route rules with allowed roles. Also define global response headers for a content security policy, nosniff content type handling and strict transport security.
Authenticate with Azure for deployment.
Flags: --subscription-id, -S | --resource-group, -R | --tenant-id, -T | --client-id, -C | --client-secret, -CS | --app-name, -n
Prefer interactive swa login. For service principals, supply the client secret from a CI secret store or the environment, and keep the literal secret value out of command lines, chat and logs. On shared machines, clear cached credentials with swa login --clear-credentials after use.
Configure a new SWA project based on an existing frontend and (optional) API. Detects frameworks automatically.
Build frontend and/or API.
Flags: --app-location, -a | --api-location, -i | --output-location, -O | --app-build-command, -A | --api-build-command, -I
Start local development emulator.
Common framework ports:
| Framework | Port |
|---|---|
React/Vue/Next.js | 3000 |
Angular | 4200 |
Vite | 5173 |
Key flags:
--port, -p - Emulator port (default: 4280)--api-location, -i - API folder path--api-port, -j - API port (default: 7071)--run, -r - Command to start dev server. Review the command with the user before running it.--open, -o - Open browser automatically--ssl, -s - Enable HTTPSDeploy to Azure Static Web Apps. Before every deploy, confirm the app name, subscription and target environment with the user, and default to a dry run or a preview deploy.
Get deployment token:
SWA_CLI_DEPLOYMENT_TOKEN, set by the user or the CI secret store outside the agent session and scoped to the deploy command or CI deploy step only. Keep it out of the global environment and keep environment contents out of output.Key flags:
--env - Target environment (preview or production)--deployment-token, -d - Deployment token. Supply the token through the environment variable or swa login instead. Treat any token as secret, refer to it only by its variable name, and keep its value out of chat, command lines and logs.--app-name, -n - Azure SWA resource nameInitialize database connections.
Keep database connection strings in environment variables or app settings, keep credentials out of generated config files, and keep env and secret files out of version control.
Always run swa init before swa start or swa deploy. Do not manually create swa-cli.config.json.
api/src/functions/message.js):Anonymous functions rely on route rules with allowed roles in staticwebapp.config.json for access control. Validate and limit the length of user input such as the name parameter, and return it only inside JSON.
staticwebapp.config.json:swa-cli.config.json:Supported API runtimes: node:20, node:22, dotnet:8.0, dotnet-isolated:8.0, python:3.10, python:3.11
.github/workflows/azure-static-web-apps.yml:
AZURE_STATIC_WEB_APPS_API_TOKENWorkflow security:
Workflow settings:
app_location - Frontend source pathapi_location - API source pathoutput_location - Built output folderskip_app_build: true - Skip if pre-builtapp_build_command - Custom build command| Issue | Solution |
|---|---|
404 on client routes | Add |
API returns 404 | Verify |
Build output not found | Verify |
Auth not working locally | Use |
CORS errors | APIs under |
Deployment token expired | Regenerate in Azure Portal → Static Web App → Manage deployment token |
Config not applied | Ensure |
Local API timeout | Default is 45 seconds; optimize function or check for blocking calls |
Debug commands:
Resolved configuration and verbose logs can contain tokens or credentials. Redact them before sharing or pasting into chat.
Get started with chainctlchainctl skill install public/github/azure-static-web-apps:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/github/skills/azure-static-web-apps:latest
MIT
HARDENING.md
LICENSE
SKILL.md