Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply csp to webview #1043

Merged
merged 2 commits into from
Jan 23, 2025
Merged

apply csp to webview #1043

merged 2 commits into from
Jan 23, 2025

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Jan 23, 2025


High Level Summary of Changes:

  • Webview Improvements: The webview display has been enhanced to lock down the Content Security Policy (CSP), ensuring that only authorized sources can load resources. This change aims for an additional layer of security.

  • Refactor of Webview Creation and Management:

    • state.showWebview() is introduced, which centralizes the logic for creating and showing or revealing the webview panel.
    • The logic to find or create a webview panel has been removed from various command handlers, streamlining the process.
  • Simplified CSP Policy: A more restrictive but safer CSP policy now applies to the webview, preventing unauthorized scripts and resources from loading.

Summary:

The core enhancement here is around improving security posture through refinement of content serving rules and better management of UI components within your application.

AI-generated content by pr-describe may be incorrect

Copy link

LGTM 🚀

The PR introduces significant improvements to web view handling by encapsulating the logic within ExtensionState rather than relying on global variables. This change makes the architecture more modular and easier to manage, which is a positive direction for maintaining and scaling the feature.

Specifically:

  • The showWebview method centralizes the creation and management of the web view, avoiding state management across different parts of the codebase.
  • By using an instance method on ExtensionState, rather than a singleton, it ensures that each extension instance can manage its own webviews, allowing for potential future parallel support (e.g., multiple workspaces).

Overall, this change enhances maintainability and scalability of the web view functionality. 🎉

AI-generated content by pr-review may be incorrect

@pelikhan pelikhan merged commit 7b2fd83 into main Jan 23, 2025
12 checks passed
@pelikhan pelikhan deleted the webcsp branch January 23, 2025 19:25
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.

1 participant