-
Notifications
You must be signed in to change notification settings - Fork 416
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
Merge [email protected] to main #864
Conversation
Feat/issue and pr template
…rning Remove deprecated warning
Unify uuid generation functions
Fix the pretty str function
…arams Fix/activating active flow with params
…ement Fix posture management and include option for idling posture.
Added correct python command version Signed-off-by: Ravinder Mahajan <[email protected]>
Signed-off-by: Ravinder Mahajan <[email protected]>
Signed-off-by: Ravinder Mahajan <[email protected]>
Feat: Upgrade LangChain to Version 0.3
Fix/nemollm test
…er-message fix: update relevant_chunks retrieval logic
fix: resolve conflict
Update guardrails-library.md
refactor: use SandboxedEnvironment for Jinja2 templates
Signed-off-by: Ravinder Mahajan <[email protected]>
Doc: Added correct python command version
…800) * update getting started doc * fix pre commit setup command
…o package Signed-off-by: Ashish Sardana <[email protected]>
feat(config): allow extra fields in AdapterConfig
chore(workflows): remove comments
This commit updates the `test_railsignore.py` to use the system's temporary directory for the `.railsignore` file. This change addresses issues with tests on Windows OS by ensuring the `.railsignore` file is created in a writable location
This workflow tests the published distribution of the package from PyPI daily. It sets up Python environments for versions 3.9, 3.10, and 3.11, installs the package, starts the server, and checks its status. This ensures the published package works as expected.
Replace underscores with hyphen in Colang 2 filenames and folders
server_endpoint = pai_config.server_endpoint | ||
enabled_entities = getattr(pai_config, source).entities | ||
|
||
if "api.private-ai.com" in server_endpoint and not pai_api_key: |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
api.private-ai.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to parse the server_endpoint
URL and check its hostname to ensure it matches the expected value. This can be done using the urlparse
function from the urllib.parse
module. Specifically, we will:
- Import the
urlparse
function. - Parse the
server_endpoint
URL to extract its hostname. - Check if the hostname matches the expected value (
api.private-ai.com
).
-
Copy modified line R20 -
Copy modified lines R47-R48
@@ -19,3 +19,3 @@ | ||
import os | ||
|
||
from urllib.parse import urlparse | ||
from nemoguardrails import RailsConfig | ||
@@ -46,3 +46,4 @@ | ||
|
||
if "api.private-ai.com" in server_endpoint and not pai_api_key: | ||
parsed_url = urlparse(server_endpoint) | ||
if parsed_url.hostname == "api.private-ai.com" and not pai_api_key: | ||
raise ValueError( |
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.
@letmerecall would you please have a look at these issuesc? Thanks!
Returns: | ||
True if PII is detected, False otherwise. | ||
""" | ||
if "api.private-ai.com" in server_endpoint and not api_key: |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
api.private-ai.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to replace the substring check with a more secure method using urlparse
to parse the URL and then check the hostname. This ensures that the check is performed on the actual hostname rather than any part of the URL string.
- Parse the
server_endpoint
URL usingurlparse
. - Extract the hostname from the parsed URL.
- Check if the hostname matches the expected value (
api.private-ai.com
).
-
Copy modified lines R45-R47
@@ -44,3 +44,5 @@ | ||
""" | ||
if "api.private-ai.com" in server_endpoint and not api_key: | ||
from urllib.parse import urlparse | ||
parsed_url = urlparse(server_endpoint) | ||
if parsed_url.hostname == "api.private-ai.com" and not api_key: | ||
raise ValueError("'api_key' is required for Private AI cloud API.") |
|
||
while True: | ||
railsignore_file = current_path / ".railsignore" | ||
if railsignore_file.exists() and railsignore_file.is_file(): |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that the constructed file path is contained within a safe root directory. We will normalize the path using os.path.normpath
and then check that the normalized path starts with the root directory. This will prevent directory traversal attacks.
- Normalize the
current_path
in theget_railsignore_path
function. - Check that the normalized path starts with the root directory.
-
Copy modified lines R329-R331 -
Copy modified lines R334-R335
@@ -328,5 +328,9 @@ | ||
""" | ||
current_path = Path(path) if path else Path.cwd() | ||
root_path = Path.cwd() | ||
current_path = Path(path) if path else root_path | ||
current_path = current_path.resolve() | ||
|
||
while True: | ||
if not str(current_path).startswith(str(root_path)): | ||
raise Exception("Access to the specified path is not allowed.") | ||
railsignore_file = current_path / ".railsignore" |
return ignored_patterns | ||
|
||
# File doesn't exist or is empty | ||
if not railsignore_path.exists() or not os.path.getsize(railsignore_path): |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that the railsignore_path
is validated before it is used in file operations. This can be done by normalizing the path and ensuring it is within a predefined safe directory. We will use os.path.normpath
to normalize the path and then check if it starts with the safe root directory.
- Define a safe root directory.
- Normalize the
railsignore_path
. - Check if the normalized path starts with the safe root directory.
- Raise an exception if the path is not within the safe directory.
-
Copy modified lines R353-R362
@@ -352,2 +352,12 @@ | ||
|
||
# Define the safe root directory | ||
safe_root = Path("/safe/root/directory").resolve() | ||
|
||
# Normalize the railsignore_path | ||
normalized_path = railsignore_path.resolve() | ||
|
||
# Check if the normalized path is within the safe root directory | ||
if not str(normalized_path).startswith(str(safe_root)): | ||
raise ValueError("Access to the specified path is not allowed.") | ||
|
||
# File doesn't exist or is empty |
return ignored_patterns | ||
|
||
# File doesn't exist or is empty | ||
if not railsignore_path.exists() or not os.path.getsize(railsignore_path): |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to ensure that the railsignore_path
is properly validated before being used. This involves normalizing the path and ensuring it is within a safe root directory. We can achieve this by modifying the get_railsignore_path
function to include these checks.
- Normalize the
railsignore_path
usingos.path.normpath
. - Ensure the normalized path starts with a predefined safe root directory.
-
Copy modified lines R329-R334
@@ -328,3 +328,8 @@ | ||
""" | ||
current_path = Path(path) if path else Path.cwd() | ||
base_path = Path.cwd() | ||
current_path = Path(path) if path else base_path | ||
current_path = current_path.resolve() | ||
|
||
if not str(current_path).startswith(str(base_path)): | ||
raise ValueError("Access to the specified path is not allowed.") | ||
|
return ignored_patterns | ||
|
||
try: | ||
with open(railsignore_path, "r") as f: |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that the railsignore_path
is validated before being used in file operations. This involves normalizing the path and ensuring it is within a safe root directory. We will implement this validation in the get_railsignore_patterns
function.
- Normalize the
railsignore_path
usingos.path.normpath
. - Ensure the normalized path starts with a predefined safe root directory.
-
Copy modified lines R353-R362
@@ -352,2 +352,12 @@ | ||
|
||
# Normalize the path | ||
railsignore_path = Path(os.path.normpath(railsignore_path)) | ||
|
||
# Define a safe root directory | ||
safe_root = Path("/safe/root/directory") | ||
|
||
# Ensure the normalized path starts with the safe root directory | ||
if not str(railsignore_path).startswith(str(safe_root)): | ||
raise ValueError("Access to the specified path is not allowed.") | ||
|
||
# File doesn't exist or is empty |
Fix typos in the example prompts to remove some of the IDE warnings
…sion Update colang extension install instructions
Fix and improve multi modal demo
Update underscore folder names to new hyphen format
Fix GTP spelling
Feature: migrate to poetry
Add support for llama-3.2 models
No description provided.