Skip to content

Conversation

@nick-y-snyk
Copy link
Contributor

@nick-y-snyk nick-y-snyk commented Dec 15, 2025

Description

image image

Provide description of this PR and changes, if linked Jira ticket doesn't cover it in full.

Checklist

Screenshots / GIFs

Visuals that may help the reviewer. Please add screenshots for any UI change. GIFs are most welcome!

@snyk-io
Copy link

snyk-io bot commented Dec 15, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@nick-y-snyk
Copy link
Contributor Author

dropping internalautoscan property because it's already handled in ls
image

Introduces BaseSnykUserControl to eliminate duplicate settings synchronization code across all WinForms settings pages. When settings change in the HTML modal window, the base class automatically reloads from disk and updates all WinForms controls.

Key changes:
- Add BaseSnykUserControl base class with SettingsChanged event handling
- Extend Language Server initialization options with new settings (BaseUrl, RiskScoreThreshold, FilterSeverity, AdditionalEnv)
- Remove InternalAutoScan flag and auto-scan trigger logic from Language Client
- Add severity filter properties (FilterCritical/High/Medium/Low) to options
- Implement GetAdditionalEnvAsync/SaveAdditionalEnvAsync in SnykOptionsManager
- Update all UserControls to inherit from BaseSnykUserControl
- Add logging and error handling to HTML settings window
- Extend ScanCommandConfig with pre/post scan command properties
/// <returns>HTML string for configuration UI, or null if unavailable</returns>
public static async Task<string> GetConfigHtmlAsync(IJsonRpc rpc, CancellationToken cancellationToken = default)
{
if (rpc == null) return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a log here? Not sure how common this will be.

}

// Fallback: try priorityScore first, then riskScore
return AdditionalData.PriorityScore > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a fallback? Would Product not always be set?

- Migrate to regex-based CSS variable replacement (inspired by IntelliJ plugin)
- Replace var(--vscode-*, fallback) patterns with actual VS theme colors
- Fix scrollbar theming to adapt properly to dark/light themes
- Use proper VS tool window colors for consistent theming across all elements
- Add browser feature control keys for better WebBrowser rendering
- Adjust modal window dimensions for better content display
- Fix ScanCommandConfig property name: Command -> PreScanCommand
{
ThreadHelper.JoinableTaskFactory.Run(async () =>
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

InjectIdeBridgeFunctions();

// Hide loading label
DebugLabel.Visibility = Visibility.Collapsed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is DebugLabel ?

Comment on lines 145 to 174
private async Task<string> GetHtmlContentAsync()
{
// Try to get HTML from Language Server (with retries)
for (int i = 0; i < 3; i++)
{
try
{
var lsHtml = await LanguageServerCommands.GetConfigHtmlAsync(
languageServerRpc,
System.Threading.CancellationToken.None);
if (!string.IsNullOrEmpty(lsHtml))
{
Logger.Information("Successfully loaded settings HTML from Language Server");
return lsHtml;
}
Logger.Warning("Language Server returned empty HTML on attempt {Attempt}", i + 1);
}
catch (Exception ex)
{
Logger.Warning(ex, "Failed to get HTML from Language Server on attempt {Attempt} of 3", i + 1);
}

if (i < 2)
await Task.Delay(1000);
}

// Fall back to embedded HTML
Logger.Warning("Falling back to embedded HTML after 3 failed Language Server attempts");
return HtmlResourceLoader.LoadFallbackHtml(options);
}
Copy link
Contributor

@ShawkyZ ShawkyZ Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just check if LangaugeServer is initialized ? If not load fallback

/// Must be ComVisible for IE11 WebBrowser control's ObjectForScripting.
/// </summary>
[ComVisible(true)]
public class ConfigScriptingBridge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this only used for the new Html Settings? If yes, please rename it for clarity since the name is too generic

Copy link
Contributor

@ShawkyZ ShawkyZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check my comments, happy to pair and go through these changes together.

SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", appName, 11001); // IE11 mode
SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", appName, 1);
SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", appName, 1);
SetBrowserFeatureControlKey("FEATURE_96DPI_PIXEL", appName, 1); // Force 96 DPI pixel scaling
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for other solutions

}
}

private void SetBrowserFeatureControlKey(string feature, string appName, int value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must not manipulate the Windows registry

@rrama rrama temporarily deployed to snyk-msbuild-envs January 8, 2026 17:57 — with GitHub Actions Inactive
@rrama rrama temporarily deployed to snyk-msbuild-envs January 8, 2026 17:57 — with GitHub Actions Inactive
@rrama rrama temporarily deployed to snyk-msbuild-envs January 8, 2026 17:57 — with GitHub Actions Inactive
The new page can be enabled (shown on startup) by setting `AutoOpenOnStartup` to `true` and specifying a path for `DEBUG_HTML_FILE_PATH`.
@rrama rrama temporarily deployed to snyk-msbuild-envs January 9, 2026 17:17 — with GitHub Actions Inactive
@rrama rrama temporarily deployed to snyk-msbuild-envs January 9, 2026 17:17 — with GitHub Actions Inactive
@rrama rrama temporarily deployed to snyk-msbuild-envs January 9, 2026 17:17 — with GitHub Actions Inactive
The new settings page is not DPI aware, so I am disabling the flag which falsely says we are. This fixes issues with dropdowns being rendered incorrectly.
Also made the debug HTML page actually not supress errors like it says.
@rrama rrama deployed to snyk-msbuild-envs January 9, 2026 18:33 — with GitHub Actions Active
@rrama rrama temporarily deployed to snyk-msbuild-envs January 9, 2026 18:33 — with GitHub Actions Inactive
@rrama rrama temporarily deployed to snyk-msbuild-envs January 9, 2026 18:33 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants