Add scripts for resolving and verifying Chromium binary paths

- Implemented `chrome-path.js` to define functions for locating Chromium binaries across different platforms and nested directories.
- Added `verify-chromium.js` to check for the presence of the Chromium binary and log the results, including candidate paths checked.
- The scripts support Linux, Windows, and macOS environments, enhancing the flexibility of Chromium binary detection.
This commit is contained in:
master
2025-10-22 09:14:36 +03:00
parent 104d5813c2
commit c377229931
131 changed files with 23191 additions and 3461 deletions

View File

@@ -1,27 +1,28 @@
using StellaOps.Scanner.Analyzers.Lang.Node;
using StellaOps.Scanner.Analyzers.Lang.Tests.Harness;
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
namespace StellaOps.Scanner.Analyzers.Lang.Tests.Node;
public sealed class NodeLanguageAnalyzerTests
{
[Fact]
public async Task WorkspaceFixtureProducesDeterministicOutputAsync()
{
var cancellationToken = TestContext.Current.CancellationToken;
var fixturePath = TestPaths.ResolveFixture("lang", "node", "workspaces");
var goldenPath = Path.Combine(fixturePath, "expected.json");
var analyzers = new ILanguageAnalyzer[]
{
new NodeLanguageAnalyzer()
};
await LanguageAnalyzerTestHarness.AssertDeterministicAsync(
fixturePath,
goldenPath,
analyzers,
cancellationToken);
}
}
using System.IO;
using StellaOps.Scanner.Analyzers.Lang.DotNet;
using StellaOps.Scanner.Analyzers.Lang.Tests.Harness;
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
namespace StellaOps.Scanner.Analyzers.Lang.Tests.DotNet;
public sealed class DotNetLanguageAnalyzerTests
{
[Fact]
public async Task SimpleFixtureProducesDeterministicOutputAsync()
{
var cancellationToken = TestContext.Current.CancellationToken;
var fixturePath = TestPaths.ResolveFixture("lang", "dotnet", "simple");
var goldenPath = Path.Combine(fixturePath, "expected.json");
var analyzers = new ILanguageAnalyzer[]
{
new DotNetLanguageAnalyzer()
};
await LanguageAnalyzerTestHarness.AssertDeterministicAsync(
fixturePath,
goldenPath,
analyzers,
cancellationToken);
}
}

View File

@@ -1,35 +0,0 @@
[
{
"analyzerId": "java",
"componentKey": "purl::pkg:maven/com/example/demo@1.0.0",
"purl": "pkg:maven/com/example/demo@1.0.0",
"name": "demo",
"version": "1.0.0",
"type": "maven",
"usedByEntrypoint": true,
"metadata": {
"artifactId": "demo",
"displayName": "Demo Library",
"groupId": "com.example",
"jarPath": "libs/demo.jar",
"manifestTitle": "Demo",
"manifestVendor": "Example Corp",
"manifestVersion": "1.0.0",
"packaging": "jar"
},
"evidence": [
{
"kind": "file",
"source": "MANIFEST.MF",
"locator": "libs/demo.jar!META-INF/MANIFEST.MF",
"value": "title=Demo;version=1.0.0;vendor=Example Corp"
},
{
"kind": "file",
"source": "pom.properties",
"locator": "libs/demo.jar!META-INF/maven/com.example/demo/pom.properties",
"sha256": "c20f36aa1b9d89d28cf9ed131519ffd6287a4dac0c7cb926130496f3f8157bf1"
}
]
}
]

View File

@@ -0,0 +1,73 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v10.0/linux-x64"
},
"targets": {
".NETCoreApp,Version=v10.0": {
"Sample.App/1.0.0": {
"dependencies": {
"StellaOps.Toolkit": "1.2.3",
"Microsoft.Extensions.Logging": "9.0.0"
}
},
"StellaOps.Toolkit/1.2.3": {
"dependencies": {
"Microsoft.Extensions.Logging": "9.0.0"
},
"runtime": {
"lib/net10.0/StellaOps.Toolkit.dll": {
"assemblyVersion": "1.2.3.0",
"fileVersion": "1.2.3.0"
}
}
},
"Microsoft.Extensions.Logging/9.0.0": {
"runtime": {
"lib/net9.0/Microsoft.Extensions.Logging.dll": {
"assemblyVersion": "9.0.0.0",
"fileVersion": "9.0.24.52809"
}
}
}
},
".NETCoreApp,Version=v10.0/linux-x64": {
"StellaOps.Toolkit/1.2.3": {
"runtime": {
"runtimes/linux-x64/native/libstellaops.toolkit.so": {}
}
},
"Microsoft.Extensions.Logging/9.0.0": {
"runtime": {
"runtimes/linux-x64/lib/net9.0/Microsoft.Extensions.Logging.dll": {}
}
}
},
".NETCoreApp,Version=v10.0/win-x86": {
"Microsoft.Extensions.Logging/9.0.0": {
"runtime": {
"runtimes/win-x86/lib/net9.0/Microsoft.Extensions.Logging.dll": {}
}
}
}
},
"libraries": {
"Sample.App/1.0.0": {
"type": "project",
"serviceable": false
},
"StellaOps.Toolkit/1.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-FAKE_TOOLKIT_SHA==",
"path": "stellaops.toolkit/1.2.3",
"hashPath": "stellaops.toolkit.1.2.3.nupkg.sha512"
},
"Microsoft.Extensions.Logging/9.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-FAKE_LOGGING_SHA==",
"path": "microsoft.extensions.logging/9.0.0",
"hashPath": "microsoft.extensions.logging.9.0.0.nupkg.sha512"
}
}
}

View File

@@ -0,0 +1,35 @@
{
"runtimeOptions": {
"tfm": "net10.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "10.0.0"
},
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "10.0.0"
}
],
"runtimeGraph": {
"runtimes": {
"linux-x64": {
"fallbacks": [
"linux",
"unix"
]
},
"win-x86": {
"fallbacks": [
"win",
"any"
]
}
}
}
}
}

View File

@@ -0,0 +1,62 @@
[
{
"analyzerId": "dotnet",
"componentKey": "purl::pkg:nuget/microsoft.extensions.logging@9.0.0",
"purl": "pkg:nuget/microsoft.extensions.logging@9.0.0",
"name": "Microsoft.Extensions.Logging",
"version": "9.0.0",
"type": "nuget",
"usedByEntrypoint": false,
"metadata": {
"deps.path[0]": "Sample.App.deps.json",
"deps.rid[0]": "linux-x64",
"deps.rid[1]": "win-x86",
"deps.tfm[0]": ".NETCoreApp,Version=v10.0",
"package.hashPath[0]": "microsoft.extensions.logging.9.0.0.nupkg.sha512",
"package.id": "Microsoft.Extensions.Logging",
"package.id.normalized": "microsoft.extensions.logging",
"package.path[0]": "microsoft.extensions.logging/9.0.0",
"package.serviceable": "true",
"package.sha512[0]": "sha512-FAKE_LOGGING_SHA==",
"package.version": "9.0.0"
},
"evidence": [
{
"kind": "file",
"source": "deps.json",
"locator": "Sample.App.deps.json",
"value": "Microsoft.Extensions.Logging/9.0.0"
}
]
},
{
"analyzerId": "dotnet",
"componentKey": "purl::pkg:nuget/stellaops.toolkit@1.2.3",
"purl": "pkg:nuget/stellaops.toolkit@1.2.3",
"name": "StellaOps.Toolkit",
"version": "1.2.3",
"type": "nuget",
"usedByEntrypoint": false,
"metadata": {
"deps.dependency[0]": "microsoft.extensions.logging",
"deps.path[0]": "Sample.App.deps.json",
"deps.rid[0]": "linux-x64",
"deps.tfm[0]": ".NETCoreApp,Version=v10.0",
"package.hashPath[0]": "stellaops.toolkit.1.2.3.nupkg.sha512",
"package.id": "StellaOps.Toolkit",
"package.id.normalized": "stellaops.toolkit",
"package.path[0]": "stellaops.toolkit/1.2.3",
"package.serviceable": "true",
"package.sha512[0]": "sha512-FAKE_TOOLKIT_SHA==",
"package.version": "1.2.3"
},
"evidence": [
{
"kind": "file",
"source": "deps.json",
"locator": "Sample.App.deps.json",
"value": "StellaOps.Toolkit/1.2.3"
}
]
}
]

View File

@@ -1,134 +0,0 @@
[
{
"analyzerId": "node",
"componentKey": "purl::pkg:npm/left-pad@1.3.0",
"purl": "pkg:npm/left-pad@1.3.0",
"name": "left-pad",
"version": "1.3.0",
"type": "npm",
"usedByEntrypoint": false,
"metadata": {
"integrity": "sha512-LEFTPAD",
"path": "packages/app/node_modules/left-pad",
"resolved": "https://registry.example/left-pad-1.3.0.tgz"
},
"evidence": [
{
"kind": "file",
"source": "package.json",
"locator": "packages/app/node_modules/left-pad/package.json"
}
]
},
{
"analyzerId": "node",
"componentKey": "purl::pkg:npm/lib@2.0.1",
"purl": "pkg:npm/lib@2.0.1",
"name": "lib",
"version": "2.0.1",
"type": "npm",
"usedByEntrypoint": false,
"metadata": {
"integrity": "sha512-LIB",
"path": "packages/lib",
"resolved": "https://registry.example/lib-2.0.1.tgz",
"workspaceLink": "packages/app/node_modules/lib",
"workspaceMember": "true",
"workspaceRoot": "packages/lib"
},
"evidence": [
{
"kind": "file",
"source": "package.json",
"locator": "packages/app/node_modules/lib/package.json"
},
{
"kind": "file",
"source": "package.json",
"locator": "packages/lib/package.json"
}
]
},
{
"analyzerId": "node",
"componentKey": "purl::pkg:npm/root-workspace@1.0.0",
"purl": "pkg:npm/root-workspace@1.0.0",
"name": "root-workspace",
"version": "1.0.0",
"type": "npm",
"usedByEntrypoint": false,
"metadata": {
"path": ".",
"private": "true"
},
"evidence": [
{
"kind": "file",
"source": "package.json",
"locator": "package.json"
}
]
},
{
"analyzerId": "node",
"componentKey": "purl::pkg:npm/shared@3.1.4",
"purl": "pkg:npm/shared@3.1.4",
"name": "shared",
"version": "3.1.4",
"type": "npm",
"usedByEntrypoint": false,
"metadata": {
"integrity": "sha512-SHARED",
"path": "packages/shared",
"resolved": "https://registry.example/shared-3.1.4.tgz",
"workspaceLink": "packages/app/node_modules/shared",
"workspaceMember": "true",
"workspaceRoot": "packages/shared",
"workspaceTargets": "packages/lib"
},
"evidence": [
{
"kind": "file",
"source": "package.json",
"locator": "packages/app/node_modules/shared/package.json"
},
{
"kind": "file",
"source": "package.json",
"locator": "packages/shared/package.json"
}
]
},
{
"analyzerId": "node",
"componentKey": "purl::pkg:npm/workspace-app@1.0.0",
"purl": "pkg:npm/workspace-app@1.0.0",
"name": "workspace-app",
"version": "1.0.0",
"type": "npm",
"usedByEntrypoint": false,
"metadata": {
"installScripts": "true",
"path": "packages/app",
"policyHint.installLifecycle": "postinstall",
"script.postinstall": "node scripts/setup.js",
"workspaceMember": "true",
"workspaceRoot": "packages/app",
"workspaceTargets": "packages/lib;packages/shared"
},
"evidence": [
{
"kind": "file",
"source": "package.json",
"locator": "packages/app/package.json"
},
{
"kind": "metadata",
"source": "package.json:scripts",
"locator": "packages/app/package.json#scripts.postinstall",
"value": "node scripts/setup.js",
"sha256": "f9ae4e4c9313857d1acc31947cee9984232cbefe93c8a56c718804744992728a"
}
]
}
]

View File

@@ -1,49 +0,0 @@
{
"name": "root-workspace",
"version": "1.0.0",
"lockfileVersion": 3,
"packages": {
"": {
"name": "root-workspace",
"version": "1.0.0",
"private": true,
"workspaces": [
"packages/*"
]
},
"packages/app": {
"name": "workspace-app",
"version": "1.0.0"
},
"packages/lib": {
"name": "lib",
"version": "2.0.1",
"resolved": "https://registry.example/lib-2.0.1.tgz",
"integrity": "sha512-LIB"
},
"packages/shared": {
"name": "shared",
"version": "3.1.4",
"resolved": "https://registry.example/shared-3.1.4.tgz",
"integrity": "sha512-SHARED"
},
"packages/app/node_modules/lib": {
"name": "lib",
"version": "2.0.1",
"resolved": "https://registry.example/lib-2.0.1.tgz",
"integrity": "sha512-LIB"
},
"packages/app/node_modules/shared": {
"name": "shared",
"version": "3.1.4",
"resolved": "https://registry.example/shared-3.1.4.tgz",
"integrity": "sha512-SHARED"
},
"packages/app/node_modules/left-pad": {
"name": "left-pad",
"version": "1.3.0",
"resolved": "https://registry.example/left-pad-1.3.0.tgz",
"integrity": "sha512-LEFTPAD"
}
}
}

View File

@@ -1,10 +0,0 @@
{
"name": "root-workspace",
"version": "1.0.0",
"private": true,
"workspaces": [
"packages/app",
"packages/lib",
"packages/shared"
]
}

View File

@@ -1,5 +0,0 @@
{
"name": "left-pad",
"version": "1.3.0",
"main": "index.js"
}

View File

@@ -1,5 +0,0 @@
{
"name": "lib",
"version": "2.0.1",
"main": "index.js"
}

View File

@@ -1,5 +0,0 @@
{
"name": "shared",
"version": "3.1.4",
"main": "index.js"
}

View File

@@ -1,11 +0,0 @@
{
"name": "workspace-app",
"version": "1.0.0",
"dependencies": {
"lib": "workspace:../lib",
"shared": "workspace:../shared"
},
"scripts": {
"postinstall": "node scripts/setup.js"
}
}

View File

@@ -1,7 +0,0 @@
{
"name": "lib",
"version": "2.0.1",
"dependencies": {
"left-pad": "1.3.0"
}
}

View File

@@ -1,7 +0,0 @@
{
"name": "shared",
"version": "3.1.4",
"dependencies": {
"lib": "workspace:../lib"
}
}

View File

@@ -1,33 +0,0 @@
using StellaOps.Scanner.Analyzers.Lang.Java;
using StellaOps.Scanner.Analyzers.Lang.Tests.Harness;
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
namespace StellaOps.Scanner.Analyzers.Lang.Tests.Java;
public sealed class JavaLanguageAnalyzerTests
{
[Fact]
public async Task ExtractsMavenArtifactFromJarAsync()
{
var cancellationToken = TestContext.Current.CancellationToken;
var root = TestPaths.CreateTemporaryDirectory();
try
{
var jarPath = JavaFixtureBuilder.CreateSampleJar(root);
var usageHints = new LanguageUsageHints(new[] { jarPath });
var analyzers = new ILanguageAnalyzer[] { new JavaLanguageAnalyzer() };
var goldenPath = TestPaths.ResolveFixture("java", "basic", "expected.json");
await LanguageAnalyzerTestHarness.AssertDeterministicAsync(
fixturePath: root,
goldenPath: goldenPath,
analyzers: analyzers,
cancellationToken: cancellationToken,
usageHints: usageHints);
}
finally
{
TestPaths.SafeDelete(root);
}
}
}

View File

@@ -29,12 +29,11 @@
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StellaOps.Scanner.Analyzers.Lang\StellaOps.Scanner.Analyzers.Lang.csproj" />
<ProjectReference Include="..\StellaOps.Scanner.Analyzers.Lang.Java\StellaOps.Scanner.Analyzers.Lang.Java.csproj" />
<ProjectReference Include="..\StellaOps.Scanner.Analyzers.Lang.Node\StellaOps.Scanner.Analyzers.Lang.Node.csproj" />
<ProjectReference Include="..\StellaOps.Scanner.Core\StellaOps.Scanner.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StellaOps.Scanner.Analyzers.Lang\StellaOps.Scanner.Analyzers.Lang.csproj" />
<ProjectReference Include="..\StellaOps.Scanner.Analyzers.Lang.DotNet\StellaOps.Scanner.Analyzers.Lang.DotNet.csproj" />
<ProjectReference Include="..\StellaOps.Scanner.Core\StellaOps.Scanner.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />

View File

@@ -35,17 +35,18 @@ public static class TestPaths
}
}
public static string ResolveProjectRoot()
{
var directory = AppContext.BaseDirectory;
while (!string.IsNullOrEmpty(directory))
{
if (File.Exists(Path.Combine(directory, "StellaOps.Scanner.Analyzers.Lang.Tests.csproj")))
{
return directory;
}
directory = Path.GetDirectoryName(directory) ?? string.Empty;
public static string ResolveProjectRoot()
{
var directory = AppContext.BaseDirectory;
while (!string.IsNullOrEmpty(directory))
{
var matches = Directory.EnumerateFiles(directory, "StellaOps.Scanner.Analyzers.Lang*.Tests.csproj", SearchOption.TopDirectoryOnly);
if (matches.Any())
{
return directory;
}
directory = Path.GetDirectoryName(directory) ?? string.Empty;
}
throw new InvalidOperationException("Unable to locate project root.");