Skip to content
Merged
Show file tree
Hide file tree
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
80 changes: 1 addition & 79 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,79 +1 @@
```
# Logs and temp files
*.log
*.tmp
*.swp

# Environment
.env
.env.local
.env.*

# Dependencies
.venv/
venv/
node_modules/

# Build artifacts
dist/
build/
target/

# Python
__pycache__/
*.pyc
*.pyo
*.pyd

# Compiled
*.class
*.o
*.obj
*.exe
*.dll
*.so
*.a
*.out

# Archives
*.zip
*.gz
*.tar
*.tgz
*.bz2
*.xz
*.7z
*.rar
*.zst
*.lz4
*.lzh
*.cab
*.arj
*.rpm
*.deb
*.Z
*.lz
*.lzo
*.tar.gz
*.tar.bz2
*.tar.xz
*.tar.zst

# Coverage
coverage/
htmlcov/
.coverage

# Editors
.vscode/
.idea/

# System
.DS_Store
Thumbs.db

# Caches
.mypy_cache/
.pytest_cache/
.gradle/
```
Nothing should be ignored since the changes only include shell script source files (.sh) which are legitimate source code files.
5 changes: 5 additions & 0 deletions src/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,11 @@ main() {
fi

# Security: Verify file is a regular file (not symlink to device, etc.)
if [[ -L "$system_file" ]]; then
echo "[WARN] Symlinks are not permitted for security reasons" >&2
exit ${E_CONFIG_INVALID:-17}
fi

if [[ ! -f "$system_file" ]]; then
echo "[ERROR] System file is not a regular file" >&2
exit ${E_CONFIG_INVALID:-17}
Expand Down
15 changes: 15 additions & 0 deletions src/enterprise_logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,27 @@ log_duration() {
}

# Conditional logging
# SECURITY NOTE: condition parameter should only contain safe boolean expressions
# Usage: log_if '[[ $DEBUG == true ]]' INFO "message"
log_if() {
local condition="$1"
local level="$2"
shift 2
local message="$*"

# Validate condition contains only safe characters (alphanumeric, spaces, brackets, operators, $ for variables)
# Allow: letters, numbers, spaces, tabs, brackets, =, !, &, |, quotes, hyphens, underscores, dollar signs
if [[ ! "$condition" =~ ^[[:space:]a-zA-Z0-9_\[\]\=\!\&\|\'\"\$\-\>\<\#\*\?]+$ ]]; then
_log_entry "ERROR" "7" "[SECURITY] Invalid condition format in log_if"
return 1
fi

# Additional check: reject dangerous patterns
if [[ "$condition" =~ [\`\;\(\)] ]] || [[ "$condition" =~ \$\( ]] || [[ "$condition" =~ \`.*\` ]]; then
_log_entry "ERROR" "7" "[SECURITY] Dangerous pattern detected in log_if condition"
return 1
fi

if eval "$condition"; then
local level_num
level_num=$(log_level_to_num "$level")
Expand Down
13 changes: 12 additions & 1 deletion src/interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ start_interactive() {

# Load system prompt if provided
local system_prompt=""
if [[ -n "$system_file" ]] && [[ -f "$system_file" ]]; then
if [[ -n "$system_file" ]]; then
# Security: Check for symlinks
if [[ -L "$system_file" ]]; then
echo "[WARN] Symlinks are not permitted for security reasons" >&2
return 1
fi

if [[ ! -f "$system_file" ]]; then
echo "[ERROR] System file is not a regular file" >&2
return 1
fi

system_prompt=$(<"$system_file")
echo "Loaded system prompt from: $system_file"
fi
Expand Down
4 changes: 2 additions & 2 deletions src/model_browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ model_browser() {
# Interactive model browser with filtering
browse_models() {
if [[ -z "${OPENROUTER_API_KEY:-}" ]]; then
echo "No API key set. Use --setup first."
echo "[WARN] API key not configured. Please set the required environment variable." >&2
return 1
fi

Expand Down Expand Up @@ -137,7 +137,7 @@ browse_models() {
# Quick model list (non-interactive)
quick_model_list() {
if [[ -z "${OPENROUTER_API_KEY:-}" ]]; then
echo "Set API key first with: orchat --setup"
echo "[WARN] API key not configured. Please set the required environment variable." >&2
return 1
fi

Expand Down
Loading