-
Notifications
You must be signed in to change notification settings - Fork 153
feat(power-pages): add security skills #151
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
Merged
Ramachandran R (r-ramachandran)
merged 30 commits into
main
from
power-pages/features/security-skills
May 26, 2026
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
89f896d
feat(security-review): add HTML report generation and supporting docu…
5d4014b
feat(security-review): enhance security review flow and parallelize s…
b105654
Refactor manage-code-scan and manage-site-scan skills for clarity and…
14407ec
fix(security-review): update terminology for clarity in security revi…
32f991e
refactor(manage-site-scan): update descriptions and remove quick scan…
117aca6
feat(security-review): add HTML report generation and supporting docu…
9377fb1
Add scan-site skill and related scripts for Power Pages security scan…
2cf007a
refactor(skills): remove progress tracking tables from manage-firewal…
d58e718
refactor(manage-firewall, manage-headers, scan-code, scan-site, secur…
9d4d2f1
refactor(manage-firewall): enforce rule naming conventions and update…
9cd494a
Refactor firewall management scripts and documentation
02ac085
Refactor scan-site scripts to use Power Platform API; update command …
5568193
Add headers reference documentation and remove obsolete scripts
70bb4e8
refactor(manage-headers): enhance security recommendations and clarif…
ae11b96
refactor(manage-headers): update skill tracking instructions for clar…
86bf558
Refactor scan-code commands and tool installation documentation
85b43a1
refactor(scan-code): update scan depth options and enhance trivy comm…
8801899
refactor(security-review): improve clarity and consistency in documen…
04a7793
Merge branch 'main' into power-pages/features/security-skills
9a1756d
fix(scan-code): clarify description for Basic risk coverage in user p…
7cd643f
Refactor security review and scan report scripts
40c7677
Enhance scan-code and scan-site skills with unified JSON output and t…
a029116
fix: update usage examples to replace <guid> with <portal-id> in scri…
062d950
Refactor scan-code functionality: remove scripts and documentation
4c87aca
feat(security-review): integrate scan-code skill for local source and…
9bce600
Revert "feat(security-review): integrate scan-code skill for local so…
1686d49
feat(security-review): enhance security review skill with improved fl…
a396013
Refactor scan-site and security-review skills for improved user exper…
82a49a2
Merge branch 'main' into power-pages/features/security-skills
89b695b
test(power-pages): address Copilot PR #151 review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const REQUIRED_FLAGS = [ | ||
| 'reportName', | ||
| 'inputDir', | ||
| 'siteName', | ||
| 'goalLabel', | ||
| 'scopeLabel', | ||
| 'output', | ||
| ]; | ||
|
|
||
| const SECTION_MAP = { | ||
| 'scan-site.json': { id: 'site-scan', label: 'Live Site Scan', icon: '◐' }, | ||
| 'manage-headers.json': { id: 'headers', label: 'Browser Headers', icon: '◑' }, | ||
| 'manage-firewall.json': { | ||
| id: 'firewall', | ||
| label: 'Web Application Firewall', | ||
| icon: '◆', | ||
| }, | ||
| 'audit-permissions.json': { id: 'permissions', label: 'Roles & Permissions', icon: '◇' }, | ||
| 'setup-auth.json': { id: 'auth', label: 'Access & Identity', icon: '◈' }, | ||
| }; | ||
|
|
||
| // Every severity a finding may carry. `pass` is shown as a stat but excluded | ||
| // from the issue count by the report template. | ||
| const SEVERITIES = ['critical', 'high', 'warning', 'medium', 'info', 'low', 'pass']; | ||
|
|
||
| const HELP = `build-review-data.js — Consolidate per-skill JSON into a single review data file. | ||
|
|
||
| Usage: | ||
| node build-review-data.js --reportName <name> --inputDir <dir> --siteName <name> --goalLabel <label> --scopeLabel <label> --output <path> [--summary <text>] [--nextStepsFile <path>] | ||
|
|
||
| Flags: | ||
| --reportName Top-bar report title (e.g., "Security Review", "Site Scan") (required) | ||
| --inputDir Directory containing per-skill review JSON files (required) | ||
| --siteName Site display name (required) | ||
| --goalLabel Plain-language goal label (required) | ||
| --scopeLabel Plain-language scope label (required) | ||
| --output Output data-file path (required) | ||
| --summary Overall plain-language summary, 2-4 sentences (optional) | ||
| --nextStepsFile Path to a JSON file containing an array of next-step strings (optional) | ||
| --help Show this help message | ||
|
|
||
| Exit codes: | ||
| 0 Success (data file written; status JSON on stdout) | ||
| 1 Invocation error (missing flag or unreadable input dir) | ||
| `; | ||
|
|
||
| function getArg(name, fallback = null) { | ||
| const idx = process.argv.indexOf('--' + name); | ||
| return idx !== -1 && idx + 1 < process.argv.length ? process.argv[idx + 1] : fallback; | ||
| } | ||
|
|
||
| function readNextSteps(filePath) { | ||
| try { | ||
| const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')); | ||
| return Array.isArray(parsed) ? parsed.filter((x) => typeof x === 'string') : []; | ||
| } catch (err) { | ||
| process.stderr.write(`Could not read next-steps file: ${err.message}\n`); | ||
| return []; | ||
| } | ||
| } | ||
|
|
||
| function formatGeneratedAt(now) { | ||
| const pad = (n) => String(n).padStart(2, '0'); | ||
| // Intl returns "GMT+5:30" on some platforms; keep only the short abbreviation when present. | ||
| const tzName = | ||
| new Intl.DateTimeFormat(undefined, { timeZoneName: 'short' }) | ||
| .formatToParts(now) | ||
| .find((p) => p.type === 'timeZoneName')?.value || ''; | ||
| const stamp = | ||
| `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ` + | ||
| `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`; | ||
| return tzName ? `${stamp} ${tzName}` : stamp; | ||
| } | ||
|
|
||
| function skippedSection(meta, reason) { | ||
| return { | ||
| id: meta.id, | ||
| icon: meta.icon, | ||
| label: meta.label, | ||
| description: '', | ||
| findings: [ | ||
| { | ||
| id: `${meta.id}-skipped`, | ||
| title: `${meta.label} check was skipped`, | ||
| details: reason || 'No additional detail.', | ||
| }, | ||
| ], | ||
| details: {}, | ||
| }; | ||
| } | ||
|
|
||
| function buildSections(inputDir, outputBasename) { | ||
| const sections = []; | ||
| const totals = Object.fromEntries(SEVERITIES.map((s) => [s, 0])); | ||
|
|
||
| for (const fileName of fs.readdirSync(inputDir).sort()) { | ||
| if (!fileName.endsWith('.json')) continue; | ||
| if (fileName === outputBasename) continue; | ||
| const meta = SECTION_MAP[fileName]; | ||
| if (!meta) continue; | ||
|
|
||
| const filePath = path.join(inputDir, fileName); | ||
| let raw; | ||
| try { | ||
| raw = JSON.parse(fs.readFileSync(filePath, 'utf8')); | ||
| } catch (err) { | ||
| process.stderr.write(`Skipping ${fileName}: ${err.message}\n`); | ||
| continue; | ||
| } | ||
|
|
||
| if (raw?.status === 'skipped') { | ||
| sections.push(skippedSection(meta, raw.reason)); | ||
| continue; | ||
| } | ||
|
|
||
| const findings = Array.isArray(raw?.findings) ? raw.findings : []; | ||
| sections.push({ | ||
| id: meta.id, | ||
| icon: meta.icon, | ||
| label: meta.label, | ||
| description: '', | ||
| findings, | ||
| details: raw?.details || {}, | ||
| }); | ||
|
|
||
| for (const f of findings) { | ||
| if (f.severity && totals[f.severity] !== undefined) totals[f.severity] += 1; | ||
| } | ||
| } | ||
|
|
||
| return { sections, totals }; | ||
| } | ||
|
|
||
| function main() { | ||
| if (process.argv.includes('--help')) { | ||
| process.stdout.write(HELP); | ||
| return; | ||
| } | ||
|
|
||
| const values = Object.fromEntries(REQUIRED_FLAGS.map((flag) => [flag, getArg(flag)])); | ||
| for (const flag of REQUIRED_FLAGS) { | ||
| if (!values[flag]) { | ||
| process.stderr.write(`Missing required flag: --${flag}\n`); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| const inputDir = values.inputDir; | ||
| const outputPath = values.output; | ||
| if (!fs.existsSync(inputDir)) { | ||
| process.stderr.write(`Input dir not found: ${inputDir}\n`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const summary = getArg('summary', ''); | ||
| const nextStepsFile = getArg('nextStepsFile'); | ||
| const nextSteps = nextStepsFile ? readNextSteps(nextStepsFile) : []; | ||
|
|
||
| const { sections, totals } = buildSections(inputDir, path.basename(outputPath)); | ||
|
|
||
| const payload = { | ||
| REPORT_NAME: values.reportName, | ||
| SITE_NAME: values.siteName, | ||
| GOAL_LABEL: values.goalLabel, | ||
| SCOPE_LABEL: values.scopeLabel, | ||
| GENERATED_AT: formatGeneratedAt(new Date()), | ||
| REVIEW_DATA: { summary: summary || '', totals, sections, nextSteps }, | ||
| }; | ||
|
|
||
| fs.mkdirSync(path.dirname(outputPath), { recursive: true }); | ||
| fs.writeFileSync(outputPath, JSON.stringify(payload, null, 2)); | ||
|
|
||
| process.stdout.write( | ||
| JSON.stringify({ | ||
| status: 'ok', | ||
| outputPath, | ||
| totals, | ||
| sectionsCount: sections.length, | ||
| }) + '\n' | ||
| ); | ||
| } | ||
|
|
||
| if (require.main === module) { | ||
| main(); | ||
| } | ||
|
|
||
| module.exports = { buildSections, formatGeneratedAt, SECTION_MAP, SEVERITIES }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.