microsoft/power-platform-skills / plugins/power-pages/skills/manage-firewall
manage-firewall
UnverifiedInspects and configures the web application firewall (WAF) in front of a Power Pages production site. Lists the current state, recommends enabling protection when it is off, and walks the user through adding, updating, or removing custom rules — IP blocks, country blocks, path blocks, and rate limits. Use when the user wants to turn on WAF, block traffic by IP or country, rate-limit login or signup pages, protect pages from brute-force attempts, restrict access to specific paths, review the current firewall configuration, or asks "is my site protected against bots / common web attacks?" — even if they say "add rate limit" or "protect login page" without mentioning "firewall" or "WAF".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.5 KB |
| references/commands.md | markdown | 11.4 KB |
| references/rule-reference.md | markdown | 8.5 KB |
| scripts/delete-rules.js | script | 1.8 KB |
| scripts/disable.js | script | 2.8 KB |
| scripts/enable.js | script | 3.0 KB |
| scripts/get-rules.js | script | 1.7 KB |
| scripts/get-status.js | script | 1.6 KB |
| scripts/set-rules.js | script | 2.8 KB |
| scripts/transform-firewall.js | script | 6.4 KB |
scripts/transform-firewall.js
View on GitHub#!/usr/bin/env node
const fs = require('fs');
const RULE_TYPE_RATE_LIMIT = 'RateLimitRule';
const HELP = `transform-firewall.js — Transform get-status.js + get-rules.js output into section findings.
Usage:
node transform-firewall.js --statusFile <path> --rulesFile <path> [--annotations <path>]
Flags:
--statusFile Path to a get-status.js stdout JSON file (required)
--rulesFile Path to a get-rules.js stdout JSON file (required)
--annotations Path to agent-provided annotations JSON (optional) — see "Annotations shape" below
--help Show this help message
Annotations shape (all keys optional):
{
"state": {
"description": "Plain-language meaning of the current firewall state",
"fix": "Suggested action if the state indicates a genuine issue"
},
"rules": {
"<RuleName>": { "description": "Plain-language summary", "fix": "Optional fix" }
}
}
Exit codes:
0 Success (unified JSON on stdout)
1 Invocation error (missing flags or unreadable file)
Examples:
node transform-firewall.js --statusFile <status-file> --rulesFile <rules-file>
node transform-firewall.js --statusFile <status-file> --rulesFile <rules-file> --annotations <annotations-file>
`;
function getArg(name) {
const idx = process.argv.indexOf('--' + name);
return idx !== -1 && idx + 1 < process.argv.length ? process.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);
}
}
function bulletList(pairs) {
return pairs.map(([k, v]) => `- ${k}: ${v}`).join('\n');
}
function buildFinding(id, title, pairs, annotation) {
const detailParts = [];
if (annotation.description) detailParts.push(annotation.description);
detailParts.push(bulletList(pairs));
return {
id,
title,
details: detailParts.join('\n\n'),
...(annotation.fix ? { fix: annotation.fix } : {}),
};
}
function customRulePairs(rule) {
const typeLabel =
rule.ruleType === RULE_TYPE_RATE_LIMIT
? 'Custom rate-limit rule'
: `Custom ${rule.ruleType || 'rule'}`;
const pairs = [['Type', typeLabel]];
if (rule.ruleType === RULE_TYPE_RATE_LIMIT) {
pairs.push([
'Threshold',
`${rule.rateLimitThreshold ?? '?'} requests / ${rule.rateLimitDurationInMinutes ?? '?'} min`,
]);
}
pairs.push(['Action', rule.action || 'unknown']);
pairs.push(['Priority', rule.priority != null ? String(rule.priority) : 'unknown']);
pairs.push(['State', rule.enabledState || 'unknown']);
return pairs;
}
// Managed-rule responses arrive with dotted, flattened keys (e.g. `properties.ruleSetVersion`)
// from the WAF endpoint, but fall back to nested `properties.*` if the service shape changes.
function managedField(rule, key) {
return rule[`properties.${key}`] ?? rule.properties?.[key];
}
function managedRulePairs(rule) {
const groups = (() => {
const value = managedField(rule, 'ruleGroups');
return Array.isArray(value) ? value : [];
})();
const ruleCount = groups.reduce(
(sum, g) => sum + (Array.isArray(g.rules) ? g.rules.length : 0),
0
);
const groupCount = groups.length;
return [
['Type', 'Managed rule set'],
['Version', managedField(rule, 'ruleSetVersion') || 'unknown'],
['Rules', `${ruleCount} across ${groupCount} group${groupCount === 1 ? '' : 's'}`],
['Provisioning state', managedField(rule, 'provisioningState') || 'unknown'],
];
}
function transform(statusResponse, rulesResponse, annotations) {
const findings = [];
let counter = 1;
const unsupportedResponse =
statusResponse.status === 'unsupported'
? statusResponse
: rulesResponse.status === 'unsupported'
? rulesResponse
: null;
if (unsupportedResponse) {
findings.push({
id: `firewall-${counter++}`,
title: 'Firewall unsupported',
details: unsupportedResponse.message || 'Feature not available.',
});
return { status: 'unsupported', findings };
}
const stateAnnotation = annotations.state || {};
findings.push({
id: `firewall-${counter++}`,
title: `Firewall state: ${statusResponse.value ?? 'unknown'}`,
...(stateAnnotation.description ? { details: stateAnnotation.description } : {}),
...(stateAnnotation.fix ? { fix: stateAnnotation.fix } : {}),
});
const body = rulesResponse.body || {};
const customRules = Array.isArray(body.CustomRules) ? body.CustomRules : [];
const managedRules = Array.isArray(body.ManagedRules) ? body.ManagedRules : [];
const ruleAnnotations = annotations.rules || {};
// Missing priorities sort last so the comparator never returns NaN.
const priorityOf = (r) => (r.priority != null ? r.priority : Number.MAX_SAFE_INTEGER);
const sortedCustom = [...customRules].sort((a, b) => priorityOf(a) - priorityOf(b));
for (const rule of sortedCustom) {
findings.push(
buildFinding(
`firewall-${counter++}`,
rule.name,
customRulePairs(rule),
ruleAnnotations[rule.name] || {}
)
);
}
const sortedManaged = [...managedRules].sort((a, b) =>
(a.name || '').localeCompare(b.name || '')
);
for (const rule of sortedManaged) {
findings.push(
buildFinding(
`firewall-${counter++}`,
rule.name,
managedRulePairs(rule),
ruleAnnotations[rule.name] || {}
)
);
}
return { status: 'ok', findings };
}
function main() {
if (process.argv.includes('--help')) {
process.stdout.write(HELP);
return 0;
}
const statusFile = getArg('statusFile');
const rulesFile = getArg('rulesFile');
const annotationsFile = getArg('annotations');
if (!statusFile || !rulesFile) {
process.stderr.write(
'Usage: node transform-firewall.js --statusFile <status-file> ' +
'--rulesFile <rules-file> [--annotations <annotations-file>]\n'
);
return 1;
}
const statusResponse = readJson(statusFile, 'status file');
const rulesResponse = readJson(rulesFile, 'rules file');
const annotations = annotationsFile ? readJson(annotationsFile, 'annotations file') : {};
process.stdout.write(
JSON.stringify(transform(statusResponse, rulesResponse, annotations)) + '\n'
);
return 0;
}
module.exports = { transform };
if (require.main === module) {
process.exit(main());
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |