Add simple build gestures, dependency copy, and test for validating rust detections.
This commit is contained in:
Родитель
c3ce95c9e1
Коммит
6dc6760264
|
@ -0,0 +1,15 @@
|
|||
@echo off
|
||||
time /T
|
||||
|
||||
pushd .\src\security_utilities_rust_ffi\
|
||||
call cargo build --release
|
||||
popd
|
||||
xcopy /Y .\src\security_utilities_rust_ffi\target\release\microsoft_security_utilities_core.dll .\refs
|
||||
xcopy /Y .\src\security_utilities_rust_ffi\target\release\microsoft_security_utilities_core.pdb .\refs
|
||||
|
||||
powershell -ExecutionPolicy RemoteSigned -File %~dp0\scripts\BuildAndTest.ps1 %*
|
||||
set result=%ERRORLEVEL%
|
||||
time /T
|
||||
echo %RESULT%
|
||||
|
||||
exit /b %RESULT%
|
|
@ -0,0 +1,2 @@
|
|||
@echo off
|
||||
powershell -ExecutionPolicy RemoteSigned -File %~dp0\scripts\BuildPackages.ps1 %*
|
Двоичные данные
refs/microsoft_security_utilities_core.dll
Двоичные данные
refs/microsoft_security_utilities_core.dll
Двоичный файл не отображается.
Двоичные данные
refs/microsoft_security_utilities_core.pdb
Двоичные данные
refs/microsoft_security_utilities_core.pdb
Двоичный файл не отображается.
|
@ -0,0 +1,87 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Build, test, and package the Microsoft.Security.Tools.Internal code base
|
||||
.DESCRIPTION
|
||||
Builds the Microsoft.Security.Tools.Internal solution for multiple target frameworks, runs tests, and creates
|
||||
NuGet packages.
|
||||
.PARAMETER Configuration
|
||||
The build configuration: Release or Debug. Default=Release
|
||||
.PARAMETER NoBuild
|
||||
Do not build.
|
||||
.PARAMETER NoTest
|
||||
Do not run tests.
|
||||
.PARAMETER NoFormat
|
||||
Do not format files based on dotnet-format tool.
|
||||
.PARAMETER EnableCoverage
|
||||
Enable CodeCoverage.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]
|
||||
[ValidateSet("Debug", "Release")]
|
||||
$Configuration="Release",
|
||||
|
||||
[switch]
|
||||
$NoBuild,
|
||||
|
||||
[switch]
|
||||
$NoTest,
|
||||
|
||||
[switch]
|
||||
$NoFormat,
|
||||
|
||||
[switch]
|
||||
$EnableCoverage,
|
||||
|
||||
[switch]
|
||||
$NoDiffCheck
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$InformationPreference = "Continue"
|
||||
|
||||
$ScriptName = $([io.Path]::GetFileNameWithoutExtension($PSCommandPath))
|
||||
$RepoRoot = $(Resolve-Path $PSScriptRoot\..).Path
|
||||
|
||||
function Exit-WithFailureMessage($scriptName, $message) {
|
||||
Write-Information "${scriptName}: $message"
|
||||
Write-Information "$scriptName FAILED."
|
||||
exit 1
|
||||
}
|
||||
|
||||
If (Test-Path "..\bld") {
|
||||
Write-Information "Deleting old build..."
|
||||
rd /s /q ..\bld
|
||||
}
|
||||
|
||||
if (-not $NoBuild) {
|
||||
Write-Information "Building Microsoft.Security.Utilities.sln (dotnet)..."
|
||||
dotnet build $RepoRoot\src\Microsoft.Security.Utilities.sln -c $Configuration -p:Deterministic=true -p:WarningsAsErrors="MSB3277"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Exit-WithFailureMessage $ScriptName "Build of \Microsoft.Security.Utilities failed."
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $NoTest) {
|
||||
Write-Information "Running tests..."
|
||||
|
||||
$CodeCoverageCommand = '--collect:"Code Coverage"'
|
||||
if (-not $EnableCoverage) {
|
||||
$CodeCoverageCommand = ""
|
||||
}
|
||||
|
||||
dotnet test $RepoRoot\src\Microsoft.Security.Utilities.sln -c $Configuration --logger trx --no-build $CodeCoverageCommand /p:IncludeTestAssembly=false
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Exit-WithFailureMessage $ScriptName "Test of \Microsoft.Security.Utilities failed."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Information "Creating packages.."
|
||||
cmd.exe /c 'BuildPackages.cmd'
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Exit-WithFailureMessage $ScriptName "Package build failed."
|
||||
}
|
||||
|
||||
Write-Information "$ScriptName SUCCEEDED."
|
|
@ -0,0 +1,41 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Build packages from compiled dlls.
|
||||
.PARAMETER Configuration
|
||||
The build configuration: Release or Debug. Default=Release
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]
|
||||
[ValidateSet("Debug", "Release")]
|
||||
$Configuration="Release"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$InformationPreference = "Continue"
|
||||
|
||||
$ScriptName = $([io.Path]::GetFileNameWithoutExtension($PSCommandPath))
|
||||
$RepoRoot = $(Resolve-Path $PSScriptRoot\..).Path
|
||||
|
||||
function Exit-WithFailureMessage($scriptName, $message) {
|
||||
Write-Information "${scriptName}: $message"
|
||||
Write-Information "$scriptName FAILED."
|
||||
exit 1
|
||||
}
|
||||
|
||||
dotnet tool update --global nbgv --version 3.3.37
|
||||
$tag = nbgv get-version --variable NugetPackageVersion
|
||||
|
||||
if ($env:MsuiNugetPackageVersion) {
|
||||
Write-Information "Overriding Nerdbank.GitVersioning assigned PackageVersion: $tag -> $env:MsuiNugetPackageVersion."
|
||||
$tag = $env:MsuiNugetPackageVersion
|
||||
}
|
||||
|
||||
dotnet pack src\Microsoft.Security.Utilities.Packages.sln -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg /p:Version=$tag -o "$RepoRoot\bld\nupkg\AnyCPU_$Configuration"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Exit-WithFailureMessage $ScriptName "Pack of Microsoft.Security.Utilities.Packages.sln failed."
|
||||
}
|
||||
|
||||
Write-Information "$ScriptName SUCCEEDED."
|
|
@ -8,6 +8,8 @@
|
|||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(SolutionDir)Build.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
|
||||
<PackageReference Include="RE2.Managed" Version="4.5.7" />
|
||||
|
@ -17,13 +19,4 @@
|
|||
<ProjectReference Include="..\Microsoft.Security.Utilities.Core\Microsoft.Security.Utilities.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.dll">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.pdb">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -59,4 +59,13 @@
|
|||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)../refs/microsoft_security_utilities_core.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="$(SolutionDir)../refs/microsoft_security_utilities_core.pdb">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\Build.props" />
|
||||
<Import Project="$(SolutionDir)Build.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
|
@ -21,16 +21,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Security.Utilities.Core\Microsoft.Security.Utilities.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.dll">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.pdb">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\Build.props" />
|
||||
<Import Project="$(SolutionDir)Build.props" />
|
||||
|
||||
<PropertyGroup Label="Package">
|
||||
<Title>$(RootNamespace)</Title>
|
||||
|
@ -40,15 +40,6 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.dll">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="../../refs/microsoft_security_utilities_core.pdb">
|
||||
<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
// Copyright(c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using FluentAssertions.Execution;
|
||||
|
||||
using Microsoft.Security.Utilities;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Tests.Microsoft.Security.Utilities.Core
|
||||
{
|
||||
|
@ -37,7 +39,11 @@ namespace Tests.Microsoft.Security.Utilities.Core
|
|||
identifiable.Signature,
|
||||
identifiable.EncodeForUrl);
|
||||
|
||||
string moniker = pattern.GetMatchMoniker(key);
|
||||
moniker.Should().NotBeNull(because: $"{pattern.Name} should produce a moniker using '{key}'");
|
||||
|
||||
int found = masker.DetectSecrets(key).Count();
|
||||
found.Should().Be(1, because: $"{moniker} should match against '{key}' a single time, not {found} time(s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<TargetFrameworks>net462</TargetFrameworks>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\Build.props" />
|
||||
<Import Project="$(SolutionDir)Build.props" />
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
|
@ -25,4 +25,5 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Security.Utilities.Core\Microsoft.Security.Utilities.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "1.4.19",
|
||||
"version": "1.4.20",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/main$",
|
||||
"^refs/heads/release/v\\d+\\.\\d+\\.\\d+$"
|
||||
|
|
Загрузка…
Ссылка в новой задаче