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

Merged
merged 1,278 commits into from
Jan 12, 2025
Merged

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

merged 1,278 commits into from
Jan 12, 2025

Conversation

odilitime
Copy link
Collaborator

@odilitime odilitime commented Jan 11, 2025

Changelog:

monilpat and others added 30 commits January 9, 2025 10:32
Fix: case-sensitive column reference in knowledge table CHECK constraint
add README_PT.md
fix: Revert "feat: Proof of Pizza - Agentic Dominos Ordering"
Complete translation in Brazilian Portuguese
image and README menu links correction (./)
@Eliza needs to be @elizaOS in order for successful installation and imports
Fixed unquoted column names.  Added required column values.
Added roomId value.
Allows getRoom() to return NULL if no room exists, and returns single room if multiple rooms exist with the same "roomId" without breaking the program.
<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 12 days 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.
Unable to commit as this autofix suggestion is now outdated
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 12 days 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.
Unable to commit as this autofix suggestion is now outdated
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 12 days 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.
Unable to commit as this autofix suggestion is now outdated
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 12 days ago

To fix the issue, we should ensure that the sanitization process is thorough and handles all potential edge cases. One effective way to achieve this is to use a well-tested sanitization library, such as sanitize-html, which is specifically designed to handle complex HTML content and remove unsafe tags and attributes.

The best way to fix the problem without changing existing functionality is to replace the current series of regular expressions with a call to the sanitize-html library. This library will provide a more robust and comprehensive sanitization process.

Suggested changeset 2
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
@@ -113,17 +113,9 @@
 
-        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, "")
+        const sanitizeHtml = require("sanitize-html");
+        return sanitizeHtml(content, {
+            allowedTags: [],
+            allowedAttributes: {}
+        })
             .replace(/\s+/g, " ")
             .replace(/\n{3,}/g, "\n\n")
-            .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "")
             .trim()
EOF
@@ -113,17 +113,9 @@

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, "")
const sanitizeHtml = require("sanitize-html");
return sanitizeHtml(content, {
allowedTags: [],
allowedAttributes: {}
})
.replace(/\s+/g, " ")
.replace(/\n{3,}/g, "\n\n")
.replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "")
.trim()
packages/core/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/packages/core/package.json b/packages/core/package.json
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -92,3 +92,4 @@
         "uuid": "11.0.3",
-        "zod": "3.23.8"
+        "zod": "3.23.8",
+        "sanitize-html": "^2.14.0"
     }
EOF
@@ -92,3 +92,4 @@
"uuid": "11.0.3",
"zod": "3.23.8"
"zod": "3.23.8",
"sanitize-html": "^2.14.0"
}
This fix introduces these dependencies
Package Version Security advisories
sanitize-html (npm) 2.14.0 None
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
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
packages/plugin-opacity/src/index.ts Dismissed Show dismissed Hide dismissed
}

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 12 days 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 12 days 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
monilpat
monilpat previously approved these changes Jan 12, 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

rferrari and others added 5 commits January 12, 2025 00:23
Currently, the Grok LLM is generating duplicate mentions at the beginning of responses. This adds a simple safeguard to deduplicate mentions before sending the tweet.
Fix: replace invalid toghether ai medium model
odilitime and others added 10 commits January 11, 2025 21:07
fix: insert missing langdetect on plugin-tts package.json
fix(client-twitter): add mention deduplication utility
feat: 🎈 perf(vscode): Set file nesting for md and DockerFile
…aram validations to api server (#2051)

* fix: remove problematic redundant uuid conversion and add api input param validations to api server

* style: use object property shorthand for roomId

* chore: update pnpm-lock.yaml

---------

Co-authored-by: Monil Patel <[email protected]>
Co-authored-by: Odilitime <[email protected]>
* fix the chat stuck in infinite loop

* perfect the PR and keep the temprature and wordsToPunish in the generate response

* Update README.md

* Trigger CI checks

---------

Co-authored-by: Odilitime <[email protected]>
* fix formatting out of the way

* fix postgress chunk uuid handling for ragKnowledge

---------

Co-authored-by: Odilitime <[email protected]>
* 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

* 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

* convert imageDescriptionsArray from let to const per lint

* remove duplicate TOGETHER in case, lint/unused var

* bump eslint so it doesn't crash

* comment out unused AkashMessage interface

* clean up unused var in catch

* bump
@odilitime odilitime merged commit 5725c00 into main Jan 12, 2025
16 of 18 checks passed
0xpi-ai pushed a commit to 0xpi-ai/NayariAI that referenced this pull request Jan 15, 2025
chore: Prep v0.1.8 (dev => main)
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.