Skip to content
Open
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
13 changes: 12 additions & 1 deletion patches/sagemaker/sagemaker-open-notebook-extension.diff
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Index: code-editor-src/extensions/sagemaker-open-notebook-extension/src/extensio
===================================================================
--- /dev/null
+++ code-editor-src/extensions/sagemaker-open-notebook-extension/src/extension.ts
@@ -0,0 +1,100 @@
@@ -0,0 +1,111 @@
+
+import * as vscode from 'vscode';
+import * as https from 'https';
Expand All @@ -154,11 +154,22 @@ Index: code-editor-src/extensions/sagemaker-open-notebook-extension/src/extensio
+ return regionRegex.test(region);
+}
+
+function isValidClusterId(clusterId: string): boolean {
+ // Cluster IDs/names are alphanumeric with hyphens and underscores only
+ const clusterIdRegex = /^[a-zA-Z0-9_-]+$/;
+ return clusterIdRegex.test(clusterId);
+}
+
+async function loadAndDisplayNotebook(fileKey: string, clusterId: string, region: string) {
+ if (!isValidRegion(region)) {
+ vscode.window.showErrorMessage('Invalid region format. Region should only contain characters, numbers, and hyphens.');
+ return;
+ }
+
+ if (clusterId && !isValidClusterId(clusterId)) {
+ vscode.window.showErrorMessage('Invalid cluster ID format. Cluster ID should only contain letters, numbers, hyphens, and underscores.');
+ return;
+ }
+
+ const bucketName = `jumpstart-cache-prod-${region}`;
+ const url = `https://${bucketName}.s3.${region}.amazonaws.com/${fileKey}`;
Expand Down
Loading