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

Fix path manipulation coverity vulnerability issue #1099

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions openfl/interface/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""CLI module."""
import logging
import os
import re
import sys
import time
import warnings
Expand Down Expand Up @@ -181,6 +182,9 @@ def cli(context, log_level, no_warnings):
# This will be overridden later with user selected debugging level
disable_warnings()
log_file = os.getenv("LOG_FILE")
# Validate log_file using allow list approach
if log_file and not re.match(r"^[\w\-.]+$", log_file):
raise ValueError("Invalid log file path")
setup_logging(log_level, log_file)
sys.stdout.reconfigure(encoding="utf-8")

Expand Down
3 changes: 2 additions & 1 deletion openfl/utilities/optimizers/numpy/yogi_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def _update_second_moment(self, grad_name: str, grad: np.ndarray) -> None:
"""
sign = np.sign(grad**2 - self.grads_second_moment[grad_name])
self.grads_second_moment[grad_name] = (
self.beta_2 * self.grads_second_moment[grad_name] + (1.0 - self.beta_2) * sign * grad**2
self.beta_2 * self.grads_second_moment[grad_name]
+ (1.0 - self.beta_2) * sign * grad**2
rajithkrishnegowda marked this conversation as resolved.
Show resolved Hide resolved
)

def step(self, gradients: Dict[str, np.ndarray]) -> None:
Expand Down
Loading