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

[SingleStore] Add SingleStore connector #32

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

Rodriguespn
Copy link
Collaborator

@Rodriguespn Rodriguespn commented Oct 1, 2024

Squash all commits into one commit

Tests results for SingleStore

Drizzle-kit tests result

image

Drizzle-orm tests result

image

Drizzle-orm type tests result

image

Integration-tests results

image

@Rodriguespn Rodriguespn self-assigned this Oct 1, 2024
console.log(wrapParam('host', options.host));
console.log(wrapParam('port', options.port, true));
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

This logs sensitive data returned by [an access to password](1) as clear text.

Copilot Autofix AI 4 months ago

To fix the problem, we should ensure that sensitive information such as passwords is not logged in clear text. One way to achieve this is to mask the password before logging it. This can be done by replacing the actual password with a placeholder (e.g., "****") or by not logging the password at all.

In this case, we will modify the code to mask the password before passing it to the wrapParam function. This ensures that even if wrapParam does not handle the 'secret' flag correctly, the sensitive information will not be exposed.

Suggested changeset 1
drizzle-kit/src/cli/validations/mysql.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/cli/validations/mysql.ts b/drizzle-kit/src/cli/validations/mysql.ts
--- a/drizzle-kit/src/cli/validations/mysql.ts
+++ b/drizzle-kit/src/cli/validations/mysql.ts
@@ -56,3 +56,4 @@
 	console.log(wrapParam('user', options.user, true));
-	console.log(wrapParam('password', options.password, true, 'secret'));
+	const maskedPassword = options.password ? '****' : undefined;
+	console.log(wrapParam('password', maskedPassword, true, 'secret'));
 	console.log(wrapParam('database', options.database));
EOF
@@ -56,3 +56,4 @@
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));
const maskedPassword = options.password ? '****' : undefined;
console.log(wrapParam('password', maskedPassword, true, 'secret'));
console.log(wrapParam('database', options.database));
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
console.log(wrapParam('host', options.host));
console.log(wrapParam('port', options.port, true));
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

This logs sensitive data returned by [an access to password](1) as clear text.

Copilot Autofix AI 4 months ago

To fix the problem, we should ensure that sensitive information such as passwords is not logged in clear text. One way to achieve this is to mask or obfuscate the sensitive data before logging it. We can modify the wrapParam function call to replace the actual password with a placeholder (e.g., "****") when logging.

  • Modify the call to wrapParam for the password field to replace the actual password with a placeholder.
  • Ensure that the placeholder is used consistently to avoid exposing the actual password.
Suggested changeset 1
drizzle-kit/src/cli/validations/postgres.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/cli/validations/postgres.ts b/drizzle-kit/src/cli/validations/postgres.ts
--- a/drizzle-kit/src/cli/validations/postgres.ts
+++ b/drizzle-kit/src/cli/validations/postgres.ts
@@ -70,3 +70,3 @@
 		console.log(wrapParam('user', options.user, true));
-		console.log(wrapParam('password', options.password, true, 'secret'));
+		console.log(wrapParam('password', '****', true, 'secret'));
 		console.log(wrapParam('database', options.database));
EOF
@@ -70,3 +70,3 @@
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));
console.log(wrapParam('password', '****', true, 'secret'));
console.log(wrapParam('database', options.database));
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
console.log(wrapParam('host', options.host));
console.log(wrapParam('port', options.port, true));
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

This logs sensitive data returned by [an access to password](1) as clear text.

Copilot Autofix AI 4 months ago

To fix the problem, we should ensure that sensitive information such as passwords is not logged in clear text. One way to achieve this is to mask or obfuscate the password before logging it. We can modify the wrapParam function call to handle the password securely by replacing the actual password with a placeholder like '<hidden>'.

Suggested changeset 1
drizzle-kit/src/cli/validations/singlestore.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/cli/validations/singlestore.ts b/drizzle-kit/src/cli/validations/singlestore.ts
--- a/drizzle-kit/src/cli/validations/singlestore.ts
+++ b/drizzle-kit/src/cli/validations/singlestore.ts
@@ -56,3 +56,3 @@
 	console.log(wrapParam('user', options.user, true));
-	console.log(wrapParam('password', options.password, true, 'secret'));
+	console.log(wrapParam('password', '<hidden>', true, 'secret'));
 	console.log(wrapParam('database', options.database));
EOF
@@ -56,3 +56,3 @@
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));
console.log(wrapParam('password', '<hidden>', true, 'secret'));
console.log(wrapParam('database', options.database));
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

statement += it.generated
? `.generatedAlwaysAs(sql\`${
it.generated.as.replace(

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that backslashes are properly escaped in addition to backticks. This can be achieved by using a regular expression with the global flag to replace all occurrences of backslashes with double backslashes, and then replace backticks with escaped backticks. This ensures that all instances of these characters are properly sanitized.

  1. Modify the replace method to first escape backslashes and then escape backticks.
  2. Ensure that the changes are made in the relevant part of the code without altering the existing functionality.
Suggested changeset 1
drizzle-kit/src/introspect-mysql.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/introspect-mysql.ts b/drizzle-kit/src/introspect-mysql.ts
--- a/drizzle-kit/src/introspect-mysql.ts
+++ b/drizzle-kit/src/introspect-mysql.ts
@@ -720,6 +720,5 @@
 			? `.generatedAlwaysAs(sql\`${
-				it.generated.as.replace(
-					/`/g,
-					'\\`',
-				)
+				it.generated.as
+					.replace(/\\/g, '\\\\')
+					.replace(/`/g, '\\`')
 			}\`, { mode: "${it.generated.type}" })`
EOF
@@ -720,6 +720,5 @@
? `.generatedAlwaysAs(sql\`${
it.generated.as.replace(
/`/g,
'\\`',
)
it.generated.as
.replace(/\\/g, '\\\\')
.replace(/`/g, '\\`')
}\`, { mode: "${it.generated.type}" })`
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

statement += it.generated
? `.generatedAlwaysAs(sql\`${
it.generated.as.replace(

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that backslashes in the input string are properly escaped before any other characters are escaped. This can be achieved by adding an additional replace call to escape backslashes before escaping backticks.

  • We will modify the createTableColumns function to include an additional replace call for backslashes.
  • Specifically, we will add it.generated.as.replace(/\\/g, '\\\\') before the existing replace call for backticks.
  • This change will be made in the file drizzle-kit/src/introspect-singlestore.ts on line 687.
Suggested changeset 1
drizzle-kit/src/introspect-singlestore.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/introspect-singlestore.ts b/drizzle-kit/src/introspect-singlestore.ts
--- a/drizzle-kit/src/introspect-singlestore.ts
+++ b/drizzle-kit/src/introspect-singlestore.ts
@@ -686,6 +686,5 @@
 			? `.generatedAlwaysAs(sql\`${
-				it.generated.as.replace(
-					/`/g,
-					'\\`',
-				)
+				it.generated.as
+					.replace(/\\/g, '\\\\')
+					.replace(/`/g, '\\`')
 			}\`, { mode: "${it.generated.type}" })`
EOF
@@ -686,6 +686,5 @@
? `.generatedAlwaysAs(sql\`${
it.generated.as.replace(
/`/g,
'\\`',
)
it.generated.as
.replace(/\\/g, '\\\\')
.replace(/`/g, '\\`')
}\`, { mode: "${it.generated.type}" })`
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Comment on lines 306 to 307
it.generated.as
.replace(/`/g, '\\`')

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that all backslashes in the input string are properly escaped. This can be achieved by using a regular expression with the global flag to replace all occurrences of backslashes with double backslashes. Additionally, we should ensure that backticks are also escaped correctly.

  • We will modify the string replacement on line 306 to first escape backslashes and then escape backticks.
  • This change will be made in the createTableColumns function within the file drizzle-kit/src/introspect-sqlite.ts.
Suggested changeset 1
drizzle-kit/src/introspect-sqlite.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/drizzle-kit/src/introspect-sqlite.ts b/drizzle-kit/src/introspect-sqlite.ts
--- a/drizzle-kit/src/introspect-sqlite.ts
+++ b/drizzle-kit/src/introspect-sqlite.ts
@@ -306,2 +306,3 @@
 				it.generated.as
+					.replace(/\\/g, '\\\\')
 					.replace(/`/g, '\\`')
EOF
@@ -306,2 +306,3 @@
it.generated.as
.replace(/\\/g, '\\\\')
.replace(/`/g, '\\`')
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@Rodriguespn Rodriguespn force-pushed the fix/squash-all-commit branch from c352c09 to b72a139 Compare October 1, 2024 22:34
@Rodriguespn Rodriguespn merged commit 42758b9 into main Oct 2, 2024
0 of 6 checks passed
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