Skip to content
Merged
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/powershell-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ jobs:
needs: refresh-psd1
name: 'Windows PowerShell 7'
runs-on: windows-latest
timeout-minutes: 20
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v7
Expand Down
2 changes: 1 addition & 1 deletion DomainDetective.Visual/DomainDetective.Visual.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0' ">
<PackageReference Include="Microsoft.Playwright" Version="1.62.0" />
<PackageReference Include="HtmlTinkerX" Version="3.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
Expand Down
31 changes: 10 additions & 21 deletions DomainDetective.Visual/DomainDetectiveVisualProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
#if NET8_0_OR_GREATER
using HtmlTinkerX;
using Microsoft.Playwright;
#endif

Expand Down Expand Up @@ -92,29 +93,17 @@ public static (string FingerprintHex, int? Width, int? Height)? BuildFingerprint
linkedCts.CancelAfter(options.BrowserCaptureTimeout);
try
{
using var playwright = await Playwright.CreateAsync()
.WaitAsync(linkedCts.Token)
.ConfigureAwait(false);
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
await using var session = await HtmlBrowser.OpenSessionAsync(url, new HtmlBrowserLaunchOptions
{
Headless = true
}).WaitAsync(linkedCts.Token).ConfigureAwait(false);
await using var context = await browser.NewContextAsync(new BrowserNewContextOptions
{
ViewportSize = new ViewportSize
{
Width = Math.Max(320, options.BrowserViewportWidth),
Height = Math.Max(240, options.BrowserViewportHeight)
},
Headless = true,
ViewportWidth = Math.Max(320, options.BrowserViewportWidth),
ViewportHeight = Math.Max(240, options.BrowserViewportHeight),
// Typosquatting probes intentionally continue through invalid certificates.
IgnoreHTTPSErrors = options.HttpRequestOptions.DisableTlsValidation
}).WaitAsync(linkedCts.Token).ConfigureAwait(false);
var page = await context.NewPageAsync().WaitAsync(linkedCts.Token).ConfigureAwait(false);
await page.GotoAsync(url, new PageGotoOptions
{
WaitUntil = WaitUntilState.NetworkIdle,
Timeout = (float)options.BrowserCaptureTimeout.TotalMilliseconds
}).WaitAsync(linkedCts.Token).ConfigureAwait(false);
IgnoreHTTPSErrors = options.HttpRequestOptions.DisableTlsValidation,
LoadState = HtmlBrowserLoadState.NetworkIdle,
Timeout = (int)Math.Min(int.MaxValue, options.BrowserCaptureTimeout.TotalMilliseconds)
}, linkedCts.Token).ConfigureAwait(false);
var page = session.Page;

if (options.BrowserPostLoadDelay > TimeSpan.Zero)
{
Expand Down
2 changes: 1 addition & 1 deletion DomainDetective.Visual/NuGet.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`DomainDetective.Visual` adds optional browser capture and image fingerprinting support for visual typosquatting analysis.

The package isolates the heavier Playwright and ImageSharp dependencies from the base `DomainDetective` package.
The package isolates HtmlTinkerX browser capture and ImageSharp dependencies from the base `DomainDetective` package. HtmlTinkerX owns browser installation and session lifetime.

On .NET Framework targets, the package supports image fingerprinting only. Browser capture requires .NET 8 or later.

Expand Down
Loading