Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .config/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@{
IncludeRules = @(
'PSAvoidUsingWriteHost',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUseCompatibleSyntax'
)
Rules = @{
PSUseCompatibleSyntax = @{
Enable = $true
TargetVersions = @('7.2','WindowsPowerShell 5.1')
}
}
}
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI (PowerShell)

on:
push:
branches: [ "main", "feat/**" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
lint-and-test:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install modules (PSScriptAnalyzer, Pester)
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
Install-Module Pester -Scope CurrentUser -Force

- name: Lint scripts with PSScriptAnalyzer (non-blocking for now)
shell: pwsh
run: |
$settings = ".config/PSScriptAnalyzerSettings.psd1"
if (!(Test-Path $settings)) { $settings = $null }
$target = (Test-Path "scripts") ? "scripts" : "."
$results = Invoke-ScriptAnalyzer -Path $target -Recurse -Settings $settings -ReportSummary -ErrorAction Continue
if ($results) {
"PSScriptAnalyzer findings (non-blocking):"
$results | Format-Table
} else {
"No PSScriptAnalyzer issues found."
}

- name: Run Pester tests
shell: pwsh
run: |
if (Test-Path "tests") {
Invoke-Pester -Path "tests" -CI -Output Detailed
} else {
"No tests directory found."
}
16 changes: 16 additions & 0 deletions .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Docs Lint (markdownlint)

on:
pull_request:
paths: ["**/*.md"]
push:
branches: [ "main", "feat/**" ]
paths: ["**/*.md"]

jobs:
markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v17
# The action will auto-read .markdownlint-cli2.jsonc at repo root
20 changes: 20 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"config": {
"default": true,

// Relaxed rules for existing README content
"MD001": false, // heading-increment
"MD009": false, // no-trailing-spaces
"MD012": false, // no-multiple-blanks
"MD022": false, // blanks-around-headings
"MD032": false, // blanks-around-lists

// Keep these relaxed ones too
"MD013": false, // line length
"MD033": false, // inline HTML
"MD041": false, // first line heading
"MD007": { "indent": 2 }
},
"globs": ["**/*.md"],
"ignores": ["**/node_modules", "**/.git"]
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
![CI](https://github.com/Johnholli/vulnerability-management-program/actions/workflows/ci.yml/badge.svg)
![Docs Lint](https://github.com/Johnholli/vulnerability-management-program/actions/workflows/markdown.yml/badge.svg)

# Vulnerability Management Program Implementation

In this project, we simulate the implementation of a comprehensive vulnerability management program, from inception to completion.
Expand Down
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions tests/Scripts.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pester v5 advisory tests — log findings, never fail CI

Import-Module Pester

Describe 'Remediation scripts (advisory only)' {
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
$scriptsDir = Join-Path $repoRoot 'scripts'

if (-not (Test-Path $scriptsDir)) {
It 'scripts directory missing (ok for now)' { $true | Should -BeTrue }
return
}

$scripts = @(Get-ChildItem -Path $scriptsDir -Filter *.ps1 -File -ErrorAction SilentlyContinue)

# Always pass; just print info for learning
It 'enumerate scripts (advisory)' {
"Found $($scripts.Count) scripts under /scripts"
$true | Should -BeTrue
}

foreach ($script in $scripts) {
It "parse check (advisory): $($script.Name)" {
$tokens = $null; $errors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile($script.FullName, [ref]$tokens, [ref]$errors)
if ($errors -and $errors.Count -gt 0) {
Write-Warning "Parser reported $($errors.Count) error(s) in $($script.Name)"
}
$true | Should -BeTrue
}

It "Write-Host advisory: $($script.Name)" {
$content = Get-Content $script.FullName -Raw
if ($content -match '\bWrite-Host\b') {
Write-Warning "Write-Host found in $($script.Name) — advisory only"
}
$true | Should -BeTrue
}
}
}
Loading