Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: 'Checkout Repository'
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.2.2
- name: 'Dependency Review'
uses: actions/dependency-review-action@56339e523c0409420f6c2c9a2f4292bbb3c07dd3 # v4.8.0
uses: actions/dependency-review-action@40c09b7dc99638e5ddb0bfd91c1673effc064d8a # v4.8.1
2 changes: 1 addition & 1 deletion .github/workflows/ossar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ jobs:

- name: Upload results to Security tab
if: steps.skip_check.outputs.should_skip != 'true'
uses: github/codeql-action/upload-sarif@64d10c13136e1c5bce3e5fbde8d4906eeaafc885
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5
with:
sarif_file: ${{ steps.ossar.outputs.sarifFile }}
4 changes: 2 additions & 2 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

- name: Initialize CodeQL
if: inputs.build_codeql == true && steps.skip_check.outputs.should_skip != 'true'
uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5
with:
languages: 'cpp'

Expand Down Expand Up @@ -356,4 +356,4 @@ jobs:

- name: Perform CodeQL Analysis
if: inputs.build_codeql == true && steps.skip_check.outputs.should_skip != 'true'
uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5
2 changes: 1 addition & 1 deletion .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
if: github.ref_name == 'main'
uses: github/codeql-action/upload-sarif@64d10c13136e1c5bce3e5fbde8d4906eeaafc885
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5
with:
sarif_file: results.sarif
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<EbpfVersion_Major>0</EbpfVersion_Major>
<EbpfVersion_Minor>22</EbpfVersion_Minor>
<EbpfVersion_Revision>0</EbpfVersion_Revision>
<EbpfVersion>$(EbpfVersion_Major).$(EbpfVersion_Minor).$(EbpfVersion_Revision)</EbpfVersion>
<EbpfVersion_Modifier/>
<EbpfVersionNoModifier>$(EbpfVersion_Major).$(EbpfVersion_Minor).$(EbpfVersion_Revision)</EbpfVersionNoModifier>
<EbpfVersion Condition="'$(EbpfVersion_Modifier)' == ''">$(EbpfVersion_Major).$(EbpfVersion_Minor).$(EbpfVersion_Revision)</EbpfVersion>
<EbpfVersion Condition="'$(EbpfVersion_Modifier)' != ''">$(EbpfVersion_Major).$(EbpfVersion_Minor).$(EbpfVersion_Revision)-$(EbpfVersion_Modifier)</EbpfVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
Expand Down
2 changes: 1 addition & 1 deletion external/ebpf-verifier
2 changes: 1 addition & 1 deletion external/usersim
2 changes: 1 addition & 1 deletion installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: MIT
<?define ProductVersion="022C44B5-8969-4B75-8DB0-73F98B1BD7DC"?>
<?define UpgradeCode="B6BCACB1-C872-4159-ABCB-43A50668056C"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:ui="http://schemas.microsoft.com/wix/UIExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="$(var.ProductVersion)" Name="eBPF for Windows" Language="1033" Version="$(var.EbpfVersion)" Manufacturer="Microsoft" UpgradeCode="$(var.UpgradeCode)">
<Product Id="$(var.ProductVersion)" Name="eBPF for Windows" Language="1033" Version="$(var.EbpfVersionNoModifier)" Manufacturer="Microsoft" UpgradeCode="$(var.UpgradeCode)">
<!-- Platform should be $(var.Platform) but the current installer doesn't support ARM64. Fortunately ARM64 can emulate x64, so setting it to x64 works. -->
<Package Description="eBPF for Windows" InstallerVersion="301" Compressed="yes" InstallScope="perMachine" Manufacturer="Microsoft" Platform="x64"/>
<MajorUpgrade AllowSameVersionUpgrades="yes"
Expand Down
2 changes: 1 addition & 1 deletion installer/ebpf-for-windows.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SPDX-License-Identifier: MIT
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);EbpfVersion=$(EbpfVersion)</DefineConstants>
<DefineConstants>$(DefineConstants);EbpfVersionNoModifier=$(EbpfVersionNoModifier)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\</OutputPath>
Expand Down
130 changes: 125 additions & 5 deletions scripts/Set-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,124 @@

param ($InputFile, $OutputFile, [parameter(Mandatory=$false)]$VCToolsRedistDir, [parameter(Mandatory=$false)]$architecture, [parameter(Mandatory=$false)]$configuration)

function Get-CurrentBranch {
$env:GIT_REDIRECT_STDERR = '2>&1'
$CurrentBranch = git branch --show-current
if ([string]::IsNullOrWhiteSpace($CurrentBranch)) {
Write-Warning "Failed to get branch from git"
return $null
}
return $CurrentBranch
}

# Returns the target or current git branch.
function Get-BuildBranch {
if (![string]::IsNullOrWhiteSpace($env:SYSTEM_PULLREQUEST_TARGETBRANCH)) {
# We are in a (AZP) pull request build.
Write-Host "Using SYSTEM_PULLREQUEST_TARGETBRANCH=$env:SYSTEM_PULLREQUEST_TARGETBRANCH to compute branch"
return $env:SYSTEM_PULLREQUEST_TARGETBRANCH

} elseif (![string]::IsNullOrWhiteSpace($env:GITHUB_BASE_REF)) {
# We are in a (GitHub Action) pull request build.
Write-Host "Using GITHUB_BASE_REF=$env:GITHUB_BASE_REF to compute branch"
return $env:GITHUB_BASE_REF

} elseif (![string]::IsNullOrWhiteSpace($env:BUILD_SOURCEBRANCH)) {
# We are in a (AZP) main build.
Write-Host "Using BUILD_SOURCEBRANCH=$env:BUILD_SOURCEBRANCH to compute branch"
$env:BUILD_SOURCEBRANCH -match 'refs/(?:heads/)?(.+)' | Out-Null
return $Matches[1]

} elseif (![string]::IsNullOrWhiteSpace($env:GITHUB_REF_NAME)) {
# We are in a (GitHub Action) main build.
Write-Host "Using GITHUB_REF_NAME=$env:GITHUB_REF_NAME to compute branch"
return $env:GITHUB_REF_NAME

} else {
# Fallback to the current branch.
return Get-CurrentBranch
}
}

function Test-IsReleaseBuild {
$buildBranch = Get-BuildBranch

# First check if it matches release/ or tags/ pattern
$matchesReleasePattern = $buildBranch -match '^release/|^tags/'

# If it doesn't match the pattern, it's not a release build
if (-not $matchesReleasePattern) {
return $false
}

# If it matches the pattern but contains 'prerelease', it's not a release build
if ($buildBranch -match 'prerelease') {
return $false
}

# It matches the pattern and doesn't contain 'prerelease', so it's a release build
return $true
}

<#
.SYNOPSIS
Get the eBPF version string, optionally with git hash appended for non-release branches.

.DESCRIPTION
This function constructs the version string from the Directory.Build.props file.
For non-release branches, it appends the git commit hash to the version only for nuspec.in files.

.PARAMETER GitCommitId
The git commit ID to append for non-release branches

.PARAMETER InputFilePath
The path to the input file being processed to determine if prerelease versioning should be applied

.RETURNS
The version string, potentially with git hash appended for nuspec.in files
#>
function Get-EbpfVersionString {
param(
[Parameter(Mandatory=$true)][string]$GitCommitId,
[Parameter(Mandatory=$true)][string]$InputFilePath
)

# Read and parse the Directory.Build.props file
$content = Get-Content -path "$PSScriptRoot\..\Directory.Build.props" -Raw -Encoding UTF8
[xml]$xml = $content

$VersionPropertyGroup = $xml.Project.PropertyGroup | Where-Object {$_.PSObject.Properties.Name -contains "Label" -and $_.Label -eq "Version"}

# Build the base version number
$baseVersion = ""
$baseVersion += $VersionPropertyGroup.EbpfVersion_Major + "."
$baseVersion += $VersionPropertyGroup.EbpfVersion_Minor + "."
$baseVersion += $VersionPropertyGroup.EbpfVersion_Revision

# Check if this is a release build
$isReleaseBuild = Test-IsReleaseBuild
$buildBranch = Get-BuildBranch

# Check if we're processing a nuspec.in file
$isNuspecFile = $InputFilePath -match '\.nuspec\.in$'

if ($isReleaseBuild) {
Write-Host "Release build detected (branch: $buildBranch). Using base version: $baseVersion"
return $baseVersion
} else {
# For non-release builds, only append git hash for nuspec.in files
if ($isNuspecFile) {
$shortHash = $GitCommitId.Substring(0, [Math]::Min(8, $GitCommitId.Length))
$versionWithHash = "$($baseVersion)-prerelease-$($shortHash)"
Write-Host "Non-release build detected (branch: $buildBranch) for nuspec.in file. Using version with git hash: $versionWithHash"
return $versionWithHash
} else {
Write-Host "Non-release build detected (branch: $buildBranch) for non-nuspec file. Using base version: $baseVersion"
return $baseVersion
}
}
}

# The git commit ID is in the include directory and is in the format:
# #define GIT_COMMIT_ID "some commit id"
$git_commit_id = Get-Content -Path "$PSScriptRoot\..\include\git_commit_id.h" -Raw -Encoding UTF8
Expand All @@ -15,14 +133,16 @@ $content = Get-Content -path "$PSScriptRoot\..\Directory.Build.props" -Raw -Enco

$VersionPropertyGroup = $xml.Project.PropertyGroup | Where-Object {$_.PSObject.Properties.Name -contains "Label" -and $_.Label -eq "Version"}

# Get the version number
$version = ""
$version += $VersionPropertyGroup.EbpfVersion_Major + "."
$version += $VersionPropertyGroup.EbpfVersion_Minor + "."
$version += $VersionPropertyGroup.EbpfVersion_Revision
# Get the final version string (with git hash if not a release branch and processing nuspec.in file)
$version_no_modifier = Get-EbpfVersionString -GitCommitId $git_commit_id -InputFilePath $InputFile
$version = $version_no_modifier
if ($VersionPropertyGroup.EbpfVersion_Modifier -ne "") {
$version += "-" + $VersionPropertyGroup.EbpfVersion_Modifier
}

$content = Get-Content $InputFile
$content = $content.Replace("{version}", $version)
$content = $content.Replace("{version_no_modifier}", $version_no_modifier)
$content = $content.Replace("{VCToolsRedistDir}", $VCToolsRedistDir)
$content = $content.Replace("{git_commit_id}", $git_commit_id)
$content = $content.Replace("{architecture}", $architecture)
Expand Down
25 changes: 21 additions & 4 deletions scripts/update-product-version.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
# Copyright (c) eBPF for Windows contributors
# SPDX-License-Identifier: MIT

param ($majorVersion, $minorVersion, $revisionNumber)
param (
[parameter(Mandatory=$true)] $majorVersion,
[parameter(Mandatory=$true)] $minorVersion,
[parameter(Mandatory=$true)] $revisionNumber,
[parameter(Mandatory=$false)]$modifier = "")

# Check if the version number is in the format X.Y.Z
if ("$majorVersion.$minorVersion.$revisionNumber" -match '^\d+\.\d+\.\d+$') {
if ("$majorVersion.$minorVersion.$revisionNumber" -match '^\d+\.\d+\.\d+.*$') {

if (Test-Path -Path ".\ebpf-for-windows.sln") {
# Set the new version number in the ebpf_version.h file.
$ebpf_version_file = "$PSScriptRoot\..\Directory.Build.props"
Write-Host -ForegroundColor DarkGreen "Updating the version number in the '$ebpf_version_file' file..."
# Replace <EbpfVersion_Major>0</EbpfVersion_Major> with <EbpfVersion_Major>$majorVersion</EbpfVersion_Major>

$newcontent = (Get-Content $ebpf_version_file -Raw -Encoding UTF8) `
$newcontent = Get-Content $ebpf_version_file -Raw -Encoding UTF8

$newcontent = $newcontent `
-replace '(?<=<EbpfVersion_Major>)\d+', $majorVersion `
-replace '(?<=<EbpfVersion_Minor>)\d+', $minorVersion `
-replace '(?<=<EbpfVersion_Revision>)\d+', $revisionNumber
if ($modifier -ne "") {
$newcontent = $newcontent -replace '(?<=<EbpfVersion_Modifier>)(.*?)(?=</EbpfVersion_Modifier>)', $modifier
$newcontent = $newcontent -replace '(?<=<EbpfVersion>)(.*?)(?=</EbpfVersion>)', "$majorVersion.$minorVersion.$revisionNumber-$modifier"
} else {
$newcontent = $newcontent -replace '(?<=<EbpfVersion_Modifier>)(.*?)(?=</EbpfVersion_Modifier>)', ''
$newcontent = $newcontent -replace '(?<=<EbpfVersion>)(.*?)(?=</EbpfVersion>)', "$majorVersion.$minorVersion.$revisionNumber"
}

$newcontent | Set-Content $ebpf_version_file -NoNewline
Write-Host -ForegroundColor DarkGreen "Version number updated to '$majorVersion.$minorVersion.$revisionNumber' in $ebpf_version_file"
$version_string = "$majorVersion.$minorVersion.$revisionNumber"
if ($modifier -ne "") {
$version_string += "-$modifier"
}
Write-Host -ForegroundColor DarkGreen "Version number updated to '$version_string' in $ebpf_version_file"

# Rebuild the solution, so to regenerate the NuGet packages and the '.o' files with the new version number.
Write-Host -ForegroundColor DarkGreen "Rebuilding the solution, please wait..."
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf2c/bpf2c.exe.manifest.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Overrides the default heap implementation with segment heap.
-->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity name="microsoft.ebpf-for-windows.bpf2c" type="win32" version="{version}.0"></assemblyIdentity>
<assemblyIdentity name="microsoft.ebpf-for-windows.bpf2c" type="win32" version="{version_no_modifier}.0"></assemblyIdentity>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2020/WindowsSettings">
<heapType>SegmentHeap</heapType>
Expand Down
3 changes: 3 additions & 0 deletions tools/redist-package/ebpf-for-windows-redist.nuspec.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<file src="ebpfnetsh.pdb" target="lib\native\bin"/>
<file src="export_program_info.exe" target="lib\native\bin"/>
<file src="export_program_info.pdb" target="lib\native\bin"/>
<!-- eBPF usermode service -->
<file src="ebpfsvc.exe" target="lib\native\bin"/>
<file src="ebpfsvc.pdb" target="lib\native\bin"/>
<!--eBPF drivers-->
<file src="eBPFCore.sys" target="lib\native\bin\drivers"/>
<file src="eBPFCore.pdb" target="lib\native\bin\drivers"/>
Expand Down
3 changes: 3 additions & 0 deletions tools/redist-package/redist-package.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ NuGet.exe pack $(OutDir)ebpf-for-windows-redist.nuspec -OutputDirectory $(OutDir
<ProjectReference Include="..\..\ebpfcore\EbpfCore.vcxproj">
<Project>{97e52abb-2f1e-4ad2-aefd-6eb7fdc0a41d}</Project>
</ProjectReference>
<ProjectReference Include="..\..\ebpfsvc\eBPFSvc.vcxproj">
<Project>{ba065b6a-38f8-4197-8f66-87c84afad513}</Project>
</ProjectReference>
<ProjectReference Include="..\..\netebpfext\sys\netebpfext.vcxproj">
<Project>{55499e36-37d4-4f86-b694-9f2990315758}</Project>
</ProjectReference>
Expand Down
Loading