-
Notifications
You must be signed in to change notification settings - Fork 202
feat: vscode extension #4104
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
base: main
Are you sure you want to change the base?
feat: vscode extension #4104
Conversation
<small | ||
className="block text-neutral-600 italic overflow-hidden whitespace-nowrap overflow-ellipsis" | ||
dangerouslySetInnerHTML={{ | ||
__html: highlightMatch(index, search), |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
title={item[displayBy]} | ||
className="font-bold" | ||
dangerouslySetInnerHTML={{ | ||
__html: highlightMatch(item[displayBy], search), |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
To fix the issue, we need to ensure that any HTML injected into the DOM via dangerouslySetInnerHTML
is sanitized to prevent XSS. The best approach is to use a library like dompurify
to sanitize the output of highlightMatch
. This ensures that any potentially malicious input is neutralized before being rendered as HTML.
Steps to fix:
- Install the
dompurify
library if it is not already installed. - Import
dompurify
into the file. - Use
DOMPurify.sanitize
to sanitize the output ofhighlightMatch
before passing it todangerouslySetInnerHTML
.
-
Copy modified line R2 -
Copy modified line R335
@@ -1,2 +1,3 @@ | ||
import React, { Fragment, useMemo, useRef, useState } from 'react' | ||
import DOMPurify from 'dompurify' | ||
import Input from '@/components/input/Input' | ||
@@ -333,3 +334,3 @@ | ||
dangerouslySetInnerHTML={{ | ||
__html: highlightMatch(item[displayBy], search), | ||
__html: DOMPurify.sanitize(highlightMatch(item[displayBy], search)), | ||
}} |
-
Copy modified lines R24-R25
@@ -23,3 +23,4 @@ | ||
"react-dom": "^19.0.0", | ||
"tailwindcss": "^4.1.3" | ||
"tailwindcss": "^4.1.3", | ||
"dompurify": "^3.2.5" | ||
}, |
Package | Version | Security advisories |
dompurify (npm) | 3.2.5 | None |
8a0b89e
to
2673372
Compare
|
||
import * as path from 'path' | ||
|
||
const folderName = path.basename(__dirname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FOLDER_NAME
?
vscode/extension/src/common/setup.ts
Outdated
export function loadServerDefaults(): IServerInfo { | ||
const packageJson = path.join(EXTENSION_ROOT_DIR, 'package.json') | ||
const content = fs.readFileSync(packageJson).toString() | ||
const config = JSON.parse(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config is unused
let rootWorkspace = workspaces[0] | ||
let root = undefined | ||
for (const w of workspaces) { | ||
if (await fs.pathExists(w.uri.fsPath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we juts use pathExistsSync
?
* | ||
* @returns The sqlmesh executable for the current workspace. | ||
*/ | ||
export const sqlmesh_exec = async (): Promise<Result<sqlmesh_exec, string>> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use camelCase
?
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example file
vscode/react/src/logo.svg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react logo
// Use a different variable name to avoid conflict with the parameter | ||
const eventPayload = { | ||
key: callbackName, | ||
payload: payload, | ||
} | ||
window.parent.postMessage({ | ||
key: "vscode_callback", | ||
payload: eventPayload, | ||
}, '*'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just use object directly payload: { ... }
?
vscode/react/index.html
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example file ?
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode' | ||
// import * as myExtension from '../../extension'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example ?
if (message && message.key) { | ||
if (message.key === "vscode_callback") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can just if (message?.key === "vscode_callback") { ... } else {}
webviewView.webview.onDidReceiveMessage( | ||
async (message) => { | ||
console.log("message received", message); | ||
if (message && message.key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have a dedicated ConsoleLog()
function to use when we need to log something and treat native console.log
as part of dev debugging that needs to be removed ?
// synchronize: { | ||
// fileEvents: workspace.createFileSystemWatcher('**/*.{sql,py}'), | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ?
if (_api) { | ||
return _api | ||
} | ||
_api = await PythonExtension.api() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe _api = _api || await PythonExtension.api()
try { | ||
const api = await getPythonExtensionAPI() | ||
|
||
if (api) { | ||
disposables.push( | ||
api.environments.onDidChangeActiveEnvironmentPath(async (e) => { | ||
const environment = await api.environments.resolveEnvironment(e.path) | ||
const isVirtualEnv = environment?.environment !== undefined | ||
const binPath = isVirtualEnv ? environment?.environment?.folderUri.fsPath : undefined | ||
|
||
onDidChangePythonInterpreterEvent.fire({ | ||
path: [e.path], | ||
resource: e.resource?.uri, | ||
isVirtualEnvironment: isVirtualEnv, | ||
binPath | ||
}) | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is trying to catch Error initializing python
and i think if await getPythonExtensionAPI()
returns null
that kinda like an error we want to catch here but having if (api) {
prevents that
const level = logLevelToTrace(channelLogLevel <= globalLogLevel ? channelLogLevel : globalLogLevel) | ||
return level | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just return logLevelToTrace(channelLogLevel <= globalLogLevel ? channelLogLevel : globalLogLevel)
5cc30c2
to
daa2f80
Compare
cdb81d1
to
a019d1c
Compare
registered logging [ci skip] format works making progress making progress sharing node modules creating the docs progress getting react server to show making progress with the server temp get calling api now need to add lineage tab making progress on vscode lineage temp progress: showing the lineage graph [ci skip] cleaning up lineage [ci skip] added ability to open files temp [ci skip] trying to implement lsp [ci skip] temp [ci skip] test [ci skip] temp [ci skip] temp [ci skip] temp [ci skip]
a019d1c
to
9d2ab34
Compare
Initial scope: