Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
**/obj/
**/.vs/
**/.vscode/
**/.github/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ The tool respects P4CONFIG file usage, as well as supports typical configuration
# Build and Test
### Build Requirments:

1. Visual Studio 2022 version 17.5.0 or later
1. Windows SDK version 10.0.26100.1742
1. Windows WDK version 10.0.26100.2454
1. Visual Studio 2022 version 17.14.0 or later
1. Windows SDK version 10.0.26100.7175
1. Windows WDK version 10.0.26100.6584

Details for installing Visual Studio 2022, the Windows Software Development Kit (SDK), and the Windows Driver Kit (WDK) can be found here:
> [Download the Windows Driver Kit](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk)
Expand Down
8 changes: 4 additions & 4 deletions deploy/pipelines/templates/p4vfs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ jobs:
inputs:
restoreSolution: '${{parameters.solutionFile}}'

- task: VSBuild@1
- task: MSBuild@1
displayName: 'Build'
timeoutInMinutes: 180
inputs:
vsVersion: '17.0'
solution: '${{parameters.solutionFile}}'
platform: '${{parameters.platform}}'
configuration: '${{parameters.configuration}}'
msbuildVersion: '17.0'
msbuildArchitecture: 'x64'
configuration: ${{parameters.configuration}}
msbuildArgs: '${{parameters.additionalBuildArguments}}'

- task: PublishSymbols@2
Expand Down
4 changes: 2 additions & 2 deletions external/OpenSSL/OpenSSL.Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.P4VFS.External
{
public class OpensslModule : Module
{
private const string OPENSSL_VERSION = "3.0.18";
private const string OPENSSL_VERSION = "3.0.21";
private const string PERL_PACKAGE_NAME = "StrawberryPerl";
private const string PERL_VERSION = "5.28.0.1";

Expand Down Expand Up @@ -75,7 +75,7 @@ private void BuildOpensslLibrary(string opensslArchiveFolder, string opensslTarg
$"@ECHO ON",
$"CALL \"{vcvarsScriptPath}\"",
$"CD /D \"{opensslArchiveFolder}\"",
$"\"{perlExe}\" Configure VC-WIN64A no-asm no-tests \"--prefix={opensslConfigurationFolder}\" \"--openssldir={opensslConfigurationFolder}-ssl\" --{configuration}",
$"\"{perlExe}\" Configure VC-WIN64A no-asm no-tests no-makedepend \"--prefix={opensslConfigurationFolder}\" \"--openssldir={opensslConfigurationFolder}-ssl\" --{configuration}",
$"IF %ERRORLEVEL% NEQ 0 EXIT /B 1",
$"nmake clean",
$"IF %ERRORLEVEL% NEQ 0 EXIT /B 1",
Expand Down
2 changes: 1 addition & 1 deletion external/P4API/P4API.Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.P4VFS.External
{
public class P4apiModule : Module
{
private const string P4API_VERSION = "r25.2";
private const string P4API_VERSION = "r26.1";
private const string P4API_VISUAL_STUDIO_EDITION = "2022";

public override string Name
Expand Down
8 changes: 8 additions & 0 deletions source/P4VFS.CodeSign/Source/CodeSign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ namespace Microsoft.P4VFS.CodeSign
public interface ICodeSignClient : IDisposable
{
bool Submit(CodeSignJob job);
CodeSignToken[] CreateTokens(bool interactive);
}

public class CodeSignToken
{
public string Name { get; set; }
public string Value { get; set; }
};

public static class CodeSignInterop
{
[DllImport("cabapi.dll", EntryPoint = "Cab_Extract", CallingConvention = CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Auto)]
Expand All @@ -32,6 +39,7 @@ public static class CodeSignResources
public const string HardwareLabPlaylistXml = "HardwareLabPlaylist.xml";
public const string SignAuthJson = "SignAuth.json";
public const string SignInputSetupJson = "SignInputSetup.json";
public const string SignInputAttestation = "SignInputAttestation.json";
public const string SignPolicyJson = "SignPolicy.json";
};

Expand Down
14 changes: 13 additions & 1 deletion source/P4VFS.CodeSign/Source/DevCenterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.P4VFS.CodeSign
{
public class DevCenterClient : ICodeSignClient
{
private static readonly string HdcVersion = "1.0";
private static readonly string HdcVersion = "2.0";
private static readonly string HdcTenant = "my";
private static readonly string HdcRootUri = $"/v{HdcVersion}/{HdcTenant}/hardware";

Expand Down Expand Up @@ -109,6 +109,18 @@ public bool Submit(CodeSignJob job)
return true;
}

public CodeSignToken[] CreateTokens(bool interactive)
{
JToken hdcSignInput = JObject.Parse(CodeSignUtilities.ExtractResourceToString(CodeSignResources.SignInputAttestation));
JToken hdcTokenManifest = hdcSignInput.SelectTokens("$.SignBatches[*].SignRequestFiles[*].Manifest").FirstOrDefault();
CodeSignJob job = null;

InitializeJob(job, hdcTokenManifest);
CodeSignToken accessToken = new CodeSignToken{ Name = "AccessToken", Value = GetCachedAccessTokenAsync().Result };

return new CodeSignToken[]{ accessToken };
}

public static bool PreprocessSignRequestFile(CodeSignJob job, JToken tokenSignRequestFile, string signFilePath)
{
JToken tokenManifest = tokenSignRequestFile.SelectToken("$.Manifest");
Expand Down
5 changes: 5 additions & 0 deletions source/P4VFS.CodeSign/Source/EsrpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public bool Submit(CodeSignJob job)
return esrpClientExitCode == 0;
}

public CodeSignToken[] CreateTokens(bool interactive)
{
return null;
}

private string CreateJobSignAuthFile(CodeSignJob job)
{
return CodeSignUtilities.ExtractResourceToFile(job.TargetFolder, CodeSignResources.SignAuthJson);
Expand Down
84 changes: 83 additions & 1 deletion source/P4VFS.CodeSign/Source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Security;
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.P4VFS.Extensions;
using Microsoft.P4VFS.Extensions.Linq;
using Microsoft.P4VFS.CoreInterop;
Expand Down Expand Up @@ -46,7 +47,19 @@ wait indefinatly until signed binaries arrive.
-i <name> Name of input json file resource for signing
-c <dir> Optional path to the folder containing EsrpClient.exe tool
-n <dir> Optional path to the folder containing nuget.exe tool if EsrpClient
folder is not specified. This may be an interactive login.
folder is not specified. This may be an interactive login


tokens Request and display short-lived access tokens for debugging
service REST APIs

P4VFS.CodeSign.exe tokens -q -a -i [-s <name>]

-q Query available codesign services
-a Request and display tokens for all services
-i Use public interative authentication for codesign service
instead of default SignAuth service principal
-s <name> Request and disply tokens for service by name
";

public static int Main(string[] args)
Expand Down Expand Up @@ -115,6 +128,9 @@ public static int Main(string[] args)
case "submit":
status = CommandSubmit(cmdArgs);
break;
case "tokens":
status = CommandTokens(cmdArgs);
break;
default:
VirtualFileSystemLog.Error("P4VFS.CodeSign Unknown Command {0}", args[argIndex]);
status = false;
Expand Down Expand Up @@ -197,13 +213,79 @@ private static bool CommandSubmit(string[] args)
return true;
}

private static bool CommandTokens(string[] args)
{
List<string> serviceNames = new List<string>();
bool query = false;
bool interactive = false;

int argIndex = 0;
for (; argIndex < args.Length; ++argIndex)
{
if (String.Compare(args[argIndex], "-s") == 0 && argIndex+1 < args.Length)
serviceNames.Add(args[++argIndex]);
else if (String.Compare(args[argIndex], "-a") == 0)
serviceNames.Add(null);
else if (String.Compare(args[argIndex], "-i") == 0)
interactive = true;
else if (String.Compare(args[argIndex], "-q") == 0)
query = true;
else
break;
}

if (argIndex < args.Length)
{
VirtualFileSystemLog.Error("Unexpected argument: {0}", args[argIndex]);
return false;
}

Type[] clientTypes = Assembly.GetExecutingAssembly()
.GetTypes()
.Where(type => type.IsAbstract == false && type.IsClass && typeof(ICodeSignClient).IsAssignableFrom(type))
.OrderBy(type => type.Name)
.ToArray();

Func<Type, string> getServiceName = (Type clientType) =>
Regex.Replace(clientType.Name, @"Client$", "", RegexOptions.IgnoreCase);

if (query)
{
VirtualFileSystemLog.Info("Available codesign services: {0}", String.Join(", ", clientTypes.Select(t => getServiceName(t))));
return true;
}

foreach (Type clientType in clientTypes)
{
string serviceName = getServiceName(clientType);
if (serviceNames.Any(name => name == null || String.Equals(name, serviceName, StringComparison.InvariantCultureIgnoreCase)))
{
foreach (CodeSignToken token in CreateCodeSignTokens(clientType, interactive))
{
VirtualFileSystemLog.Info($"{serviceName}.{token.Name} = {token.Value}\n");
}
}
}
return true;
}

private static bool SubmitCodeSignJob<ClientType>(CodeSignJob job) where ClientType : ICodeSignClient, new()
{
VirtualFileSystemLog.Info("Submitting codesign job for service {0}", typeof(ClientType).Name);
using (ICodeSignClient client = new ClientType())
{
return client.Submit(job);
}
}

private static CodeSignToken[] CreateCodeSignTokens(Type clientType, bool interactive)
{
VirtualFileSystemLog.Info("Creating codesign tokens for service {0}", clientType.Name);
using (ICodeSignClient client = Activator.CreateInstance(clientType) as ICodeSignClient)
{
return client.CreateTokens(interactive) ?? Array.Empty<CodeSignToken>();
}
}
}
}

26 changes: 26 additions & 0 deletions source/P4VFS.Console/P4VFS.Notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
Microsoft P4VFS Release Notes

Version [1.30.0.0]
* Updating to P4API 26.1
* Updating to OpenSSL 3.0.21 as recommended by P4API 26.1
* Driver security updates to address Microsoft Security Response Center recommendations
MSRC-126533, MSRC-121148, MSRC-121146, MSRC-121144, MSRC-123527, MSRC-121150, MSRC-121128
* Driver user mode control port messages now require process to have elevated access
for any file operations
* Driver P4VFS_FLT_FILE_HANDLE data shared now indirectly maps to kernel mode objects
to prevent possible tampering in user mode
* Driver user mode control port now uses structured exception handling prevent possible
access violation to user mode input and output buffer. This could be caused by a time-of-check
time-of-use (TOCTOU) race condition. This also prevents possible alignment failures
casting and using misaligned user-mode P4VFS_CONTROL_MSG & P4VFS_CONTROL_REPLY buffers.
* Driver now guarding against invalid offsets in P4VFS_UNICODE_STRING from user mode.
* Driver WPP tracing fixes for unicode file paths with FILE_ID_128 suffix
* Additional driver unit tests for internal P4VFS_FLT_FILE_HANDLE translation
* Addition of TestPush.bat script to optionally use in a post-build deployment to a
virtual machine for full development driver and user-mode testing.
* Updating unit test server to support p4d 2026.1 with default configurable security=4 and
enable database journal to avoid bug with p4d crash when deleting auth extension
* Addition to default ExcludedProcessNames of SenseNdr.exe, SenseDlpProcessor.exe
* OpenSSL configure now includes no-makedepend for a slight reduction in build time
* Fixing info output log when syncing to files that must resolve before submitting
* Addition of CodeSign 'tokens' command to request and display short-lived access tokens
for debugging service REST APIs.

Version [1.29.4.0]
* Updating to latest P4API 25.2
* Migrating to OpenSSL 3.0 LTS as recommended by P4API 25.2 with latest 3.0.18
Expand Down
2 changes: 1 addition & 1 deletion source/P4VFS.Core/Include/SettingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace FileCore {
_N( String, SyncResidentPattern, L"" ) \
_N( bool, Unattended, false ) \
_N( String, Verbosity, FileCore::LogChannel::ToString(FileCore::LogChannel::Info).c_str() ) \
_N( String, ExcludedProcessNames, L"MsSense.exe;MsMpEng.exe;SenseCE.exe;SenseIR.exe;SearchProtocolHost.exe;MpDlpService.exe" ) \
_N( String, ExcludedProcessNames, L"MsSense.exe;MsMpEng.exe;SenseCE.exe;SenseIR.exe;SearchProtocolHost.exe;MpDlpService.exe;SenseNdr.exe;SenseDlpProcessor.exe" ) \
_N( int32_t, CreateFileRetryCount, 8 ) \
_N( int32_t, CreateFileRetryWaitMs, 250 ) \
_N( int32_t, PoolDefaultNumberOfThreads, 8 ) \
Expand Down
4 changes: 2 additions & 2 deletions source/P4VFS.Core/P4VFS.Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>advapi32.lib;bcrypt.lib;ws2_32.lib;wtsapi32.lib;shlwapi.lib;shell32.lib;fltlib.lib;userenv.lib;crypt32.lib;$(PerforceApiLibFiles);$(OpenSSLApiLibFiles);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;bcrypt.lib;ws2_32.lib;wtsapi32.lib;shlwapi.lib;shell32.lib;fltlib.lib;userenv.lib;crypt32.lib;iphlpapi.lib;$(PerforceApiLibFiles);$(OpenSSLApiLibFiles);%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<AdditionalLibraryDirectories>$(PerforceApiLibDir);$(OpenSSLApiLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
Expand Down Expand Up @@ -177,7 +177,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>advapi32.lib;bcrypt.lib;ws2_32.lib;wtsapi32.lib;shlwapi.lib;shell32.lib;fltlib.lib;userenv.lib;crypt32.lib;$(PerforceApiLibFiles);$(OpenSSLApiLibFiles);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;bcrypt.lib;ws2_32.lib;wtsapi32.lib;shlwapi.lib;shell32.lib;fltlib.lib;userenv.lib;crypt32.lib;iphlpapi.lib;$(PerforceApiLibFiles);$(OpenSSLApiLibFiles);%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalLibraryDirectories>$(PerforceApiLibDir);$(OpenSSLApiLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
Expand Down
3 changes: 2 additions & 1 deletion source/P4VFS.Core/Source/DepotSyncAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ DepotSyncActionInfo FDepotSyncActionInfo::FromInfoOutput(const DepotString& info
info->m_ClientFile = match[1];
}
}
else if (std::regex_search(infoText.c_str(), match, rx.m_ActionNeedsResolve))

if (std::regex_search(infoText.c_str(), match, rx.m_ActionNeedsResolve))
{
info->m_DepotFile = match[2];
info->m_Revision = FDepotRevision::FromString(match[4]);
Expand Down
Loading
Loading