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

chore: Prep v0.1.8 (dev => main) #2171

Open
wants to merge 1,262 commits into
base: main
Choose a base branch
from
Open

chore: Prep v0.1.8 (dev => main) #2171

wants to merge 1,262 commits into from

Conversation

odilitime
Copy link
Collaborator

@odilitime odilitime commented Jan 11, 2025

antman1p and others added 30 commits January 9, 2025 16:48
Added adapter-supabase to packag.json so that the adapter will not fail to load.
Applied updates from the README.md to README_KOR.md
feat: support TEE logging and support running eliza in Intel SGX
Update README_CN to match latest English README
This reverts commit b96168d, reversing
changes made to 9e90a13.

revert pizza pr
:q
:wq
e
Fix: case-sensitive column reference in knowledge table CHECK constraint
add README_PT.md
fix: Revert "feat: Proof of Pizza - Agentic Dominos Ordering"
tcm390 and others added 24 commits January 11, 2025 14:12
fix: fix client-discord join voice action
inheritance of character from parent using extends key
fix: correct SUI/USD price calculation
update so just adding test
…sion

chore: Add UUID tests and fix version 5 bits
Update git command for checking latest release
chore: add conditionals for supabase to agent directory
* typo fix: close object

* update lockfile

* lint fixes

* processAtions can't be awaited in non-async function

* revert GoPlusType so it can work with switch statement

* bump lock

* merge, fix conflicts
feat: TTS(Text2Speech) with over 15 languages support!
<X />
</Button>
<img
src={URL.createObjectURL(selectedFile)}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that the file being processed is indeed an image and that it is safe to use. We can achieve this by validating the file type and size before creating the object URL. Additionally, we can use a library like DOMPurify to sanitize any potentially unsafe content.

  1. Validate the file type and size before creating the object URL.
  2. Use DOMPurify to sanitize the object URL if necessary.
Suggested changeset 2
client/src/components/chat.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/client/src/components/chat.tsx b/client/src/components/chat.tsx
--- a/client/src/components/chat.tsx
+++ b/client/src/components/chat.tsx
@@ -1,2 +1,3 @@
 import { Button } from "@/components/ui/button";
+import DOMPurify from 'dompurify';
 import {
@@ -149,4 +150,10 @@
         const file = e.target.files?.[0];
-        if (file && file.type.startsWith("image/")) {
+        if (file && file.type.startsWith("image/") && file.size <= 5 * 1024 * 1024) { // Limit file size to 5MB
             setSelectedFile(file);
+        } else {
+            toast({
+                variant: "destructive",
+                title: "Invalid file",
+                description: "Please select a valid image file (max 5MB).",
+            });
         }
@@ -288,3 +295,3 @@
                                 <img
-                                    src={URL.createObjectURL(selectedFile)}
+                                    src={DOMPurify.sanitize(URL.createObjectURL(selectedFile))}
                                     height="100%"
EOF
@@ -1,2 +1,3 @@
import { Button } from "@/components/ui/button";
import DOMPurify from 'dompurify';
import {
@@ -149,4 +150,10 @@
const file = e.target.files?.[0];
if (file && file.type.startsWith("image/")) {
if (file && file.type.startsWith("image/") && file.size <= 5 * 1024 * 1024) { // Limit file size to 5MB
setSelectedFile(file);
} else {
toast({
variant: "destructive",
title: "Invalid file",
description: "Please select a valid image file (max 5MB).",
});
}
@@ -288,3 +295,3 @@
<img
src={URL.createObjectURL(selectedFile)}
src={DOMPurify.sanitize(URL.createObjectURL(selectedFile))}
height="100%"
client/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/client/package.json b/client/package.json
--- a/client/package.json
+++ b/client/package.json
@@ -38,3 +38,4 @@
         "tailwindcss-animate": "^1.0.7",
-        "vite-plugin-compression": "^0.5.1"
+        "vite-plugin-compression": "^0.5.1",
+        "dompurify": "^3.2.3"
     },
EOF
@@ -38,3 +38,4 @@
"tailwindcss-animate": "^1.0.7",
"vite-plugin-compression": "^0.5.1"
"vite-plugin-compression": "^0.5.1",
"dompurify": "^3.2.3"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.3 None
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
const data = await response.json();
res.json(data);
const transcription = await openai.audio.transcriptions.create({
file: fs.createReadStream(audioFile.path),

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that the file path used in fs.createReadStream is validated and contained within a safe root directory. We can achieve this by normalizing the path using path.resolve and then checking that the normalized path starts with the intended upload directory. This will prevent path traversal attacks by ensuring that the file path does not escape the designated directory.

Suggested changeset 1
packages/client-direct/src/index.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/packages/client-direct/src/index.ts b/packages/client-direct/src/index.ts
--- a/packages/client-direct/src/index.ts
+++ b/packages/client-direct/src/index.ts
@@ -29,2 +29,12 @@
 
+const UPLOAD_DIR = path.join(process.cwd(), "data", "uploads");
+
+const validateFilePath = (filePath) => {
+    const normalizedPath = path.resolve(filePath);
+    if (!normalizedPath.startsWith(UPLOAD_DIR)) {
+        throw new Error("Invalid file path");
+    }
+    return normalizedPath;
+};
+
 const storage = multer.diskStorage({
@@ -177,3 +187,3 @@
                 const transcription = await openai.audio.transcriptions.create({
-                    file: fs.createReadStream(audioFile.path),
+                    file: fs.createReadStream(validateFilePath(audioFile.path)),
                     model: "whisper-1",
EOF
@@ -29,2 +29,12 @@

const UPLOAD_DIR = path.join(process.cwd(), "data", "uploads");

const validateFilePath = (filePath) => {
const normalizedPath = path.resolve(filePath);
if (!normalizedPath.startsWith(UPLOAD_DIR)) {
throw new Error("Invalid file path");
}
return normalizedPath;
};

const storage = multer.diskStorage({
@@ -177,3 +187,3 @@
const transcription = await openai.audio.transcriptions.create({
file: fs.createReadStream(audioFile.path),
file: fs.createReadStream(validateFilePath(audioFile.path)),
model: "whisper-1",
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
modelProvider: ModelProviderName.OLLAMA,
modelEndpointOverride: null,
},
token: "mock-token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "mock-token" is used as
authorization header
.
if (templatingEngine === "handlebars") {
const templateFunction = handlebars.compile(template);
const templateFunction = handlebars.compile(templateStr);

Check failure

Code scanning / CodeQL

Code injection Critical

Template, which may contain code, depends on a
user-provided value
.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that user input is properly sanitized or escaped before being used in the template compilation process. The best way to fix this issue is to use the handlebars.SafeString method to escape any potentially dangerous content in the user input. This will prevent code injection by treating the input as plain text rather than executable code.

Suggested changeset 1
packages/core/src/context.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/packages/core/src/context.ts b/packages/core/src/context.ts
--- a/packages/core/src/context.ts
+++ b/packages/core/src/context.ts
@@ -49,3 +49,4 @@
     if (templatingEngine === "handlebars") {
-        const templateFunction = handlebars.compile(templateStr);
+        const safeTemplateStr = new handlebars.SafeString(templateStr);
+        const templateFunction = handlebars.compile(safeTemplateStr);
         return templateFunction(state);
EOF
@@ -49,3 +49,4 @@
if (templatingEngine === "handlebars") {
const templateFunction = handlebars.compile(templateStr);
const safeTemplateStr = new handlebars.SafeString(templateStr);
const templateFunction = handlebars.compile(safeTemplateStr);
return templateFunction(state);
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 +72 to +80
return content
.replace(/```[\s\S]*?```/g, "")
.replace(/`.*?`/g, "")
.replace(/#{1,6}\s*(.*)/g, "$1")
.replace(/!\[(.*?)\]\(.*?\)/g, "$1")
.replace(/\[(.*?)\]\(.*?\)/g, "$1")
.replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3")
.replace(/<@[!&]?\d+>/g, "")
.replace(/<[^>]*>/g, "")

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that the regular expression replacements are applied repeatedly until no more replacements can be performed. This will help to fully sanitize the input string and prevent any residual unsafe text from remaining in the sanitized input.

The best way to fix this issue without changing existing functionality is to modify the preprocess method to apply each regular expression replacement in a loop until the input string no longer changes. This approach ensures that all instances of the targeted patterns are removed, effectively addressing the incomplete multi-character sanitization issue.

Suggested changeset 1
packages/core/src/ragknowledge.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/packages/core/src/ragknowledge.ts b/packages/core/src/ragknowledge.ts
--- a/packages/core/src/ragknowledge.ts
+++ b/packages/core/src/ragknowledge.ts
@@ -71,19 +71,22 @@
 
-        return content
-            .replace(/```[\s\S]*?```/g, "")
-            .replace(/`.*?`/g, "")
-            .replace(/#{1,6}\s*(.*)/g, "$1")
-            .replace(/!\[(.*?)\]\(.*?\)/g, "$1")
-            .replace(/\[(.*?)\]\(.*?\)/g, "$1")
-            .replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3")
-            .replace(/<@[!&]?\d+>/g, "")
-            .replace(/<[^>]*>/g, "")
-            .replace(/^\s*[-*_]{3,}\s*$/gm, "")
-            .replace(/\/\*[\s\S]*?\*\//g, "")
-            .replace(/\/\/.*/g, "")
-            .replace(/\s+/g, " ")
-            .replace(/\n{3,}/g, "\n\n")
-            .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "")
-            .trim()
-            .toLowerCase();
+        let previous;
+        do {
+            previous = content;
+            content = content
+                .replace(/```[\s\S]*?```/g, "")
+                .replace(/`.*?`/g, "")
+                .replace(/#{1,6}\s*(.*)/g, "$1")
+                .replace(/!\[(.*?)\]\(.*?\)/g, "$1")
+                .replace(/\[(.*?)\]\(.*?\)/g, "$1")
+                .replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3")
+                .replace(/<@[!&]?\d+>/g, "")
+                .replace(/<[^>]*>/g, "")
+                .replace(/^\s*[-*_]{3,}\s*$/gm, "")
+                .replace(/\/\*[\s\S]*?\*\//g, "")
+                .replace(/\/\/.*/g, "")
+                .replace(/\s+/g, " ")
+                .replace(/\n{3,}/g, "\n\n")
+                .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "");
+        } while (content !== previous);
+        return content.trim().toLowerCase();
     }
EOF
@@ -71,19 +71,22 @@

return content
.replace(/```[\s\S]*?```/g, "")
.replace(/`.*?`/g, "")
.replace(/#{1,6}\s*(.*)/g, "$1")
.replace(/!\[(.*?)\]\(.*?\)/g, "$1")
.replace(/\[(.*?)\]\(.*?\)/g, "$1")
.replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3")
.replace(/<@[!&]?\d+>/g, "")
.replace(/<[^>]*>/g, "")
.replace(/^\s*[-*_]{3,}\s*$/gm, "")
.replace(/\/\*[\s\S]*?\*\//g, "")
.replace(/\/\/.*/g, "")
.replace(/\s+/g, " ")
.replace(/\n{3,}/g, "\n\n")
.replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "")
.trim()
.toLowerCase();
let previous;
do {
previous = content;
content = content
.replace(/```[\s\S]*?```/g, "")
.replace(/`.*?`/g, "")
.replace(/#{1,6}\s*(.*)/g, "$1")
.replace(/!\[(.*?)\]\(.*?\)/g, "$1")
.replace(/\[(.*?)\]\(.*?\)/g, "$1")
.replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3")
.replace(/<@[!&]?\d+>/g, "")
.replace(/<[^>]*>/g, "")
.replace(/^\s*[-*_]{3,}\s*$/gm, "")
.replace(/\/\*[\s\S]*?\*\//g, "")
.replace(/\/\/.*/g, "")
.replace(/\s+/g, " ")
.replace(/\n{3,}/g, "\n\n")
.replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "");
} while (content !== previous);
return content.trim().toLowerCase();
}
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
endpoint,
headers: {
...requestHeaders,
Authorization: "[REDACTED]",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

The hard-coded value "[REDACTED]" is used as
authorization header
.
}

function parseDuration(duration: string): number {
const match = duration.match(/^(\d*\.?\d+)(h|d|w|m)$/);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '9'.
This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '9'.
log('error', `Failed to format files with Prettier: ${error.message}`);
}
try {
execSync(`npx prettier --write ${filePaths.join(" ")}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
file name
.
This shell command depends on an uncontrolled
absolute path
.
"Should indicate successful charge creation"
);
assert(
chargeResponse.text.includes("https://commerce.coinbase.com/pay/"),

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://commerce.coinbase.com/pay/
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to parse the URL and check its host against a whitelist of allowed hosts. This ensures that the URL is not maliciously crafted to bypass the substring check. We will use the url module to parse the URL and then verify the host.

  1. Import the url module.
  2. Parse the URL to extract the host.
  3. Check the host against a whitelist of allowed hosts.
  4. Update the assertion to use the new check.
Suggested changeset 1
tests/test1.mjs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/test1.mjs b/tests/test1.mjs
--- a/tests/test1.mjs
+++ b/tests/test1.mjs
@@ -2,2 +2,3 @@
 import { send, log, logError, runIntegrationTest } from "./testLibrary.mjs";
+import { URL } from "url";
 
@@ -36,3 +37,7 @@
     assert(
-        chargeResponse.text.includes("https://commerce.coinbase.com/pay/"),
+        (() => {
+            const url = new URL(chargeResponse.text.match(/https:\/\/commerce\.coinbase\.com\/pay\/[^\s]+/)[0]);
+            const allowedHosts = ["commerce.coinbase.com"];
+            return allowedHosts.includes(url.host);
+        })(),
         "Should contain valid Coinbase Commerce URL"
EOF
@@ -2,2 +2,3 @@
import { send, log, logError, runIntegrationTest } from "./testLibrary.mjs";
import { URL } from "url";

@@ -36,3 +37,7 @@
assert(
chargeResponse.text.includes("https://commerce.coinbase.com/pay/"),
(() => {
const url = new URL(chargeResponse.text.match(/https:\/\/commerce\.coinbase\.com\/pay\/[^\s]+/)[0]);
const allowedHosts = ["commerce.coinbase.com"];
return allowedHosts.includes(url.host);
})(),
"Should contain valid Coinbase Commerce URL"
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
);
assert(attachment.text.startsWith("Pay here:"), "Should have payment URL");
assert(
attachment.text.includes("https://commerce.coinbase.com/pay/"),

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://commerce.coinbase.com/pay/
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that the URL in attachment.text is parsed and its host is checked against a whitelist of allowed hosts. This will prevent malicious URLs from bypassing the check by embedding the allowed host string in unexpected locations.

  1. Parse the URL from attachment.text to extract the host.
  2. Check if the host is in a predefined list of allowed hosts.
  3. Update the assertion to use this new check.
Suggested changeset 1
tests/test1.mjs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/test1.mjs b/tests/test1.mjs
--- a/tests/test1.mjs
+++ b/tests/test1.mjs
@@ -61,3 +61,7 @@
     assert(
-        attachment.text.includes("https://commerce.coinbase.com/pay/"),
+        (() => {
+            const url = new URL(attachment.text.match(/https:\/\/commerce\.coinbase\.com\/pay\/[^\s]+/)[0]);
+            const allowedHosts = ["commerce.coinbase.com"];
+            return allowedHosts.includes(url.host);
+        })(),
         "Should have valid Coinbase Commerce URL"
EOF
@@ -61,3 +61,7 @@
assert(
attachment.text.includes("https://commerce.coinbase.com/pay/"),
(() => {
const url = new URL(attachment.text.match(/https:\/\/commerce\.coinbase\.com\/pay\/[^\s]+/)[0]);
const allowedHosts = ["commerce.coinbase.com"];
return allowedHosts.includes(url.host);
})(),
"Should have valid Coinbase Commerce URL"
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
@odilitime odilitime changed the title Prep v1.8.0 chore: Prep v1.8.0 (dev => main) Jan 11, 2025
@odilitime odilitime changed the title chore: Prep v1.8.0 (dev => main) chore: Prep v0.1.8 (dev => main) Jan 11, 2025
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

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

LGTM

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.