Add GitHub Action for super-lint (#618)

This commit is contained in:
Chuck Walbourn
2025-06-02 17:49:20 -07:00
committed by GitHub
parent c8959b2911
commit cb3be57e9c
78 changed files with 5040 additions and 4816 deletions

View File

@@ -3,28 +3,27 @@ Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
#>
function Execute-Setup {
function Invoke-Setup {
# Temporary work-around while OneFuzz does not run script from setup dir
Set-Location -Path $PSScriptRoot
Write-Log "Executing custom setup script in $(pwd)"
Write-OneFuzzLog "Executing custom setup script in $(Get-Location)"
# Exclude any uploaded DLL from known DLLs
gci -filter '*.dll' | Exclude-Library
Get-ChildItem -filter '*.dll' | Add-Exclude-Library
# Done. Useful to know that the script did not prematurely error out
Write-Log 'Setup script finished successfully'
Write-OneFuzzLog 'Setup script finished successfully'
}
# Write log statements into the event log.
function Write-Log {
function Write-OneFuzzLog {
Param(
[Parameter(Position=0,
Mandatory,
ValueFromPipeline,
ValueFromRemainingArguments)]
[String[]] $Messages,
[Parameter()] [Int] $EventId=0)
[String[]] $Messages)
Begin {
$EventSource = 'onefuzz-setup.ps1'
$EventLog = 'Application'
@@ -34,15 +33,15 @@ function Write-Log {
}
Process {
$Messages.ForEach({
Write-EventLog -LogName $EventLog -Source $EventSource -EventId $EventId -EntryType Information -Message $_
Write-EventLog -LogName $EventLog -Source $EventSource -EventId 0 -EntryType Information -Message $_
})
}
End {}
}
# This function is used to exclude DLL's that the fuzzer is dependent on. The dependent DLL's
# have been built with ASan and copied into the setup directory along with the fuzzer.
function Exclude-Library {
# have been built with ASan and copied into the setup directory along with the fuzzer.
function Add-Exclude-Library {
Param(
[Parameter(Position=0,
Mandatory,
@@ -59,34 +58,34 @@ function Exclude-Library {
$ExistingExclusions = @()
# Normalize DLL name to lowercase for comparison
if ($ExistingProperty -ne $null) {
if ($null -ne $ExistingProperty) {
$ExistingExclusions = $ExistingProperty.$Name.ForEach("ToLower")
}
# Normalize DLL name to lowercase for comparison, remove duplicates
$Libs = $Libraries.ForEach("ToLower") | Select-Object -Unique
Write-Log "Excluding libraries $Libs"
Write-OneFuzzLog "Excluding libraries $Libs"
# Discard empty strings and libraries already excluded
$Libs = $Libs.Where({$_.Length -gt 0 -and !($ExistingExclusions.Contains($_))})
# If anything remains either add or update registry key
if ($Libs.Length -gt 0) {
if ($ExistingProperty -eq $null) {
if ($null -eq $ExistingProperty) {
# Create registry key to exclude DLLs
New-ItemProperty -Path $Path -Name $Name -PropertyType MultiString -Value $Libs
Write-Log "Created known DLLs exclusions with $Libs"
Write-OneFuzzLog "Created known DLLs exclusions with $Libs"
} else {
# Update registry key to exclude DLLs
Set-ItemProperty -Path $Path -Name $Name -Value ($ExistingProperty.$Name + $Libs)
Write-Log "Updated known DLLs exclusions with $Libs"
Write-OneFuzzLog "Updated known DLLs exclusions with $Libs"
}
} else {
# DLLs already excluded
Write-Log "Known DLL exclusions already exist for $Libraries"
Write-OneFuzzLog "Known DLL exclusions already exist for $Libraries"
}
}
End {}
}
Execute-Setup
Invoke-Setup