-
Notifications
You must be signed in to change notification settings - Fork 0
Fases 7-8: snapshots btrfs, firma HMAC y métricas #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,40 @@ function configPathFor(token) { | |
| return path.join(CONFIG_DIR, `${token}.json`); | ||
| } | ||
|
|
||
| // Carga el secreto HMAC desde el entorno. Si no está definido, la firma | ||
| // queda deshabilitada (modo desarrollo o despliegues sin verificación). | ||
| function hmacSecret() { | ||
| return process.env.NEUBAT_HMAC_SECRET || ''; | ||
| } | ||
|
|
||
| // Payload determinista usado para la firma. Debe coincidir exactamente con | ||
| // la reconstrucción que hace el instalador en scripts/20-archinstall.sh. | ||
| function signingPayload(config) { | ||
| const parts = [ | ||
| String(config.token || ''), | ||
| String(config.machine_id || ''), | ||
| String(config.hostname || ''), | ||
| String(config.username || ''), | ||
| String(config.desktop || ''), | ||
| String(config.password || ''), | ||
| String(config.disk || ''), | ||
| String(config.timezone || ''), | ||
| String(config.locale || ''), | ||
| String(config.keyboard || ''), | ||
| ...(Array.isArray(config.packages) ? config.packages.sort() : []), | ||
| ...(Array.isArray(config.services) ? config.services.sort() : []) | ||
| ]; | ||
| return parts.join('|'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HMAC omits critical config fieldsMedium Severity The HMAC payload skips Additional Locations (2)Reviewed by Cursor Bugbot for commit 1e5bee6. Configure here. |
||
| } | ||
|
|
||
| function signConfig(config) { | ||
| const secret = hmacSecret(); | ||
| if (!secret) return null; | ||
| return crypto.createHmac('sha256', secret) | ||
| .update(signingPayload(config)) | ||
| .digest('hex'); | ||
| } | ||
|
|
||
| module.exports = { | ||
| PORTAL_ROOT, | ||
| CONFIG_DIR, | ||
|
|
@@ -64,5 +98,8 @@ module.exports = { | |
| readDB, | ||
| writeDB, | ||
| loadProfile, | ||
| configPathFor | ||
| configPathFor, | ||
| hmacSecret, | ||
| signingPayload, | ||
| signConfig | ||
| }; | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HMAC secret unused in Docker
Medium Severity
NEUBAT_HMAC_SECRETis documented for Docker Compose via.env, butdocker-compose.ymlnever injects it into the portal container (unlikeADMIN_TOKEN). The portal therefore never signs configs in the recommended deploy path, even when the secret is set.Reviewed by Cursor Bugbot for commit 1e5bee6. Configure here.