Skip to content
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

Fixing in-proc pipeline #4250

Merged
merged 11 commits into from
Feb 7, 2025
Merged
52 changes: 43 additions & 9 deletions check-vulnerabilities.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$projectPath = ".\src\Azure.Functions.Cli"
$projectFileName = ".\Azure.Functions.Cli.csproj"
$logFilePath = "..\..\build.log"
$skipCveFilePath = "..\..\skipPackagesCve.json"
if (-not (Test-Path $projectPath))
{
throw "Project path '$projectPath' does not exist."
Expand All @@ -12,22 +13,55 @@ $cmd = "restore"
Write-Host "dotnet $cmd"
dotnet $cmd | Tee-Object $logFilePath

$cmd = "list", "package", "--include-transitive", "--vulnerable"
$cmd = "list", "package", "--include-transitive", "--vulnerable", "--format", "json"
Write-Host "dotnet $cmd"
dotnet $cmd | Tee-Object $logFilePath

$result = Get-content $logFilePath | select-string "has no vulnerable packages given the current sources"
# Parse JSON output
$logContent = Get-Content $logFilePath -Raw | ConvertFrom-Json
$topLevelPackages = $logContent.projects.frameworks.topLevelPackages

# Load skip-cve.json
$skipCveContent = Get-Content $skipCveFilePath -Raw | ConvertFrom-Json
$skipPackages = $skipCveContent.packages

# Validate files in skipPackagesCve.json are still valid security vulnerabilities
$topLevelPackageIds = $topLevelPackages.id
$invalidSkips = $skipPackages | Where-Object { $_ -notin $topLevelPackageIds }

if ($invalidSkips.Count -gt 0) {
Write-Host "The following packages in 'skipPackagesCve.json' do not exist in the vulnerable packages list: $($invalidSkips -join ', '). Please remove these packages from the JSON file."
Exit 1
}

# Filter vulnerabilities
$vulnerablePackages = @()
foreach ($package in $topLevelPackages) {
if ($skipPackages -notcontains $package.id) {
$vulnerablePackages += $package
}
}

# Check for remaining vulnerabilities
if ($vulnerablePackages.Count -gt 0) {
Write-Host "Security vulnerabilities found (excluding skipped packages):"
$vulnerablePackages | ForEach-Object {
Write-Host "Package: $($_.id)"
Write-Host "Version: $($_.resolvedVersion)"
$_.vulnerabilities | ForEach-Object {
Write-Host "Severity: $($_.severity)"
Write-Host "Advisory: $($_.advisoryurl)"
}
}
Exit 1
} else {
Write-Host "No security vulnerabilities found (excluding skipped packages)."
}

$logFileExists = Test-Path $logFilePath -PathType Leaf
if ($logFileExists)
{
Remove-Item $logFilePath
}

cd ../..

if (!$result)
{
Write-Host "Vulnerabilities found"
Exit 1
}
cd ../..
3 changes: 0 additions & 3 deletions eng/ci/templates/official/jobs/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ jobs:
TELEMETRY_INSTRUMENTATION_KEY: $(TELEMETRY_INSTRUMENTATION_KEY)
IntegrationBuildNumber: $(INTEGRATIONBUILDNUMBER)
displayName: 'Executing build script'
- pwsh: |
.\check-vulnerabilities.ps1
displayName: "Check for security vulnerabilities"

- template: ci/sign-files.yml@eng
parameters:
Expand Down
6 changes: 3 additions & 3 deletions eng/ci/templates/public/jobs/build-test-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- pwsh: |
.\validateWorkerVersions.ps1
displayName: 'Validate worker versions'
- pwsh: |
.\check-vulnerabilities.ps1
displayName: "Check for security vulnerabilities"
condition: ne(variables['skipWorkerVersionValidation'], 'true')
- pwsh: |
.\build.ps1
Expand All @@ -53,9 +56,6 @@ jobs:
IsPublicBuild: true
IsCodeqlBuild: false
displayName: 'Executing build script'
- pwsh: |
.\check-vulnerabilities.ps1
displayName: "Check for security vulnerabilities"
- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
Expand Down
6 changes: 3 additions & 3 deletions pipelineUtilities.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ $DotnetSDKVersionRequirements = @{
}
# Update .NET 9 patch once .NET 9 has been released out of preview
'9.0' = @{
MinimalPatch = '100-preview.6.24328.19'
DefaultPatch = '100-preview.6.24328.19'
MinimalPatch = '100-rc.1.24452.12'
DefaultPatch = '100-rc.1.24452.12'

}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ function Install-DotnetVersion($Version,$Channel) {
if ($IsWindows) {
& .\$installScript -InstallDir "$env:ProgramFiles/dotnet" -Channel $Channel -Version $Version
# Installing .NET into x86 directory since the E2E App runs the tests on x86 and looks for the specified framework there
& .\$installScript -InstallDir "$env:ProgramFiles (x86)/dotnet" -Channel $Channel -Version $Version
& .\$installScript -InstallDir "$env:ProgramFiles (x86)/dotnet" -Channel $Channel -Version $Version -Architecture x86
} else {
bash ./$installScript --install-dir /usr/share/dotnet -c $Channel -v $Version
}
Expand Down
5 changes: 5 additions & 0 deletions skipPackagesCve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packages": [
"DotNetZip"
]
}
19 changes: 9 additions & 10 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
Expand Down Expand Up @@ -66,9 +66,9 @@
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet8Isolated">
<LogicalName>$(AssemblyName).Dockerfile.dotnet8Isolated</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet9Isolated">
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet9Isolated">
<LogicalName>$(AssemblyName).Dockerfile.dotnet9Isolated</LogicalName>
</EmbeddedResource>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\ExtensionsProj.csproj.template">
<LogicalName>$(AssemblyName).ExtensionsProj.csproj</LogicalName>
</EmbeddedResource>
Expand Down Expand Up @@ -287,15 +287,14 @@
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.AzureStorage.Internal" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.35.4" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.37.0" />
<PackageReference Include="Microsoft.Build" Version="17.0.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Packaging" Version="5.11.6" />
<PackageReference Include="System.Formats.Asn1" Version="6.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.1" />
<PackageReference Include="YamlDotNet" Version="6.0.0" />

<!-- Transitive dependency -->
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
Expand All @@ -307,12 +306,12 @@
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
<ItemGroup Condition="'$(NoWorkers)' != 'true'">
<PackageReference Include="Microsoft.Azure.Functions.JavaWorker" Version="2.14.0" />
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="3.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.JavaWorker" Version="2.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="3.10.1" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.0" Version="4.0.3148" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.2" Version="4.0.3220" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.4" Version="4.0.3219" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.29.0" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.2" Version="4.0.4025" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.4" Version="4.0.4026" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.34.0" />
</ItemGroup>
<Target Name="ExcludeWorkersFromReadyToRun">
<CreateItem Include="%(None.Filename)%(None.Extension)" Condition="$([System.String]::new('%(None.TargetPath)').StartsWith('workers'))" PreserveExistingMetadata="false">
Expand Down
2 changes: 1 addition & 1 deletion test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Task init_with_worker_runtime(string workerRuntime)

return CliTester.Run(new RunConfiguration
{
Commands = new[] { $"init . --worker-runtime {workerRuntime}" },
Commands = new[] { $"init . --worker-runtime {workerRuntime} --skip-npm-install" },
CheckFiles = files.ToArray(),
OutputContains = new[]
{
Expand Down
2 changes: 1 addition & 1 deletion validateWorkerVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if (-Not $hostVersion) {

function getHostFileContent([string]$filePath) {
$uri = "https://raw.githubusercontent.com/Azure/azure-functions-host/v$hostVersion/$filePath"
return removeBomIfExists((Invoke-WebRequest -Uri $uri -MaximumRetryCount 5 -RetryIntervalSec 2).Content)
return removeBomIfExists((Invoke-WebRequest -Uri $uri).Content)
}
$hostCsprojContent = getHostFileContent "src/WebJobs.Script/WebJobs.Script.csproj"
$pythonPropsContent = getHostFileContent "build/python.props"
Expand Down