microsoft/power-platform-skills / plugins/power-pages/skills/manage-headers
manage-headers
VerifiedInspects and configures the security headers a Power Pages site sends to browsers — Content Security Policy, frame and clickjacking protection, cross-origin sharing, cookie behavior, and related site settings. Identifies gaps and walks the user through fixes. Use when the user wants to review headers, fix CSP errors, allow embedding in another site, control cross-origin access, harden cookie settings, or asks "are my browser settings safe?", "fix my CSP", "set up CORS" — even if they only mention a specific header name without saying "security headers".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.9 KB |
| references/commands.md | markdown | 2.6 KB |
| references/headers-reference.md | markdown | 9.6 KB |
| scripts/transform-headers.js | script | 3.9 KB |
scripts/transform-headers.js
View on GitHub#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { loadSiteSettings } = require('../../../scripts/lib/powerpages-config');
const CSP_HEADER_NAMES = new Set([
'HTTP/Content-Security-Policy',
'HTTP/Content-Security-Policy-Report-Only',
]);
const EMPTY_RESULT = { status: 'ok', findings: [], details: {} };
const HELP = `transform-headers.js — Emit HTTP/* site-setting inventory as section data.
Usage:
node transform-headers.js --projectRoot <path> [--annotations <path>]
Flags:
--projectRoot Power Pages project root (containing .powerpages-site/)
--annotations Path to agent-provided annotations JSON (optional)
--help Show this help message
Annotations shape (all keys optional):
{
"headers": {
"HTTP/<HeaderName>": { "description": "Plain-language summary", "fix": "Optional fix" }
}
}
Exit codes:
0 Success (unified JSON on stdout — { status, findings, details })
1 Invocation error (missing --projectRoot)
Examples:
node transform-headers.js --projectRoot <project-root>
node transform-headers.js --projectRoot <project-root> --annotations <annotations-file>
`;
function getArg(name, argv) {
const idx = argv.indexOf('--' + name);
return idx !== -1 && idx + 1 < argv.length ? argv[idx + 1] : null;
}
function readJson(filePath, label) {
if (!fs.existsSync(filePath)) {
process.stderr.write(`${label} not found: ${filePath}\n`);
process.exit(1);
}
try {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (err) {
process.stderr.write(`Failed to parse ${label} (${filePath}): ${err.message}\n`);
process.exit(1);
}
}
// CSP values are long single-line strings; render one directive per line.
function formatValue(name, value) {
if (!CSP_HEADER_NAMES.has(name)) return value;
const stripped = value.trim().replace(/^"|"$/g, '');
const directives = stripped
.split(';')
.map((d) => d.trim())
.filter(Boolean);
if (directives.length <= 1) return stripped;
return directives.map((d) => ` ${d};`).join('\n');
}
function buildFinding(rec, idx, annotation) {
// YAML scalars aren't always strings (booleans, numbers, nulls all pass through here).
const value = rec.value != null ? String(rec.value) : '';
const detailParts = [];
if (annotation.description) detailParts.push(annotation.description);
detailParts.push(
'Current value:\n' + (value ? formatValue(rec.name, value) : ' (empty)')
);
return {
id: `headers-${idx + 1}`,
title: rec.name,
details: detailParts.join('\n\n'),
...(annotation.fix ? { fix: annotation.fix } : {}),
};
}
function transform(records, annotations) {
const httpRecords = records
.filter((r) => r.name?.startsWith('HTTP/'))
.sort((a, b) => a.name.localeCompare(b.name));
const headerAnnotations = annotations.headers || {};
const findings = httpRecords.map((rec, i) =>
buildFinding(rec, i, headerAnnotations[rec.name] || {})
);
return { status: 'ok', findings, details: {} };
}
function main(argv = process.argv) {
if (argv.includes('--help')) {
process.stdout.write(HELP);
return 0;
}
const projectRoot = getArg('projectRoot', argv);
const annotationsFile = getArg('annotations', argv);
if (!projectRoot) {
process.stderr.write(
'Usage: node transform-headers.js --projectRoot <path> [--annotations <path>]\n'
);
return 1;
}
const siteSettingsDir = path.join(projectRoot, '.powerpages-site', 'site-settings');
if (!fs.existsSync(siteSettingsDir)) {
process.stdout.write(
JSON.stringify({ ...EMPTY_RESULT, status: 'missing-settings' }) + '\n'
);
return 0;
}
const records = loadSiteSettings(siteSettingsDir);
const annotations = annotationsFile ? readJson(annotationsFile, 'annotations file') : {};
process.stdout.write(JSON.stringify(transform(records, annotations)) + '\n');
return 0;
}
module.exports = { transform };
if (require.main === module) {
process.exit(main());
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |