Skip to content

Commit 4d2d54a

Browse files
authored
chore: reduce the log level of vulnerability go service forwarding to debug (#3955)
Signed-off-by: anil <epipav@gmail.com>
1 parent 481bb63 commit 4d2d54a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

services/apps/git_integration/src/crowdgit/services/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
2-
import logging
32
import re
43
from urllib.parse import urlparse
54

5+
import loguru
6+
67
from crowdgit.errors import (
78
CommandExecutionError,
89
CommandTimeoutError,
@@ -168,7 +169,8 @@ async def run_shell_command(
168169
cwd: str = None,
169170
timeout: float | None = None,
170171
input_text: str | bytes | None = None,
171-
stderr_logger: logging.Logger | None = None,
172+
stderr_logger: loguru.Logger | None = None,
173+
stderr_log_level: str = "INFO",
172174
) -> str:
173175
"""
174176
Run shell command asynchronously and return output on success, raise exception on failure.
@@ -179,6 +181,7 @@ async def run_shell_command(
179181
timeout: Command timeout in seconds
180182
input_text: Text (str) or bytes to send to stdin (will automatically append newline if not present)
181183
stderr_logger: If provided, a logger whose .info() method is called with each stderr line in real-time
184+
stderr_log_level: Log level for stderr lines (default: "INFO")
182185
183186
Returns:
184187
str: Command stdout output
@@ -230,7 +233,7 @@ async def _stream() -> None:
230233
async for raw_line in process.stderr:
231234
line = _safe_decode(raw_line).rstrip()
232235
if line:
233-
stderr_logger.info(line)
236+
stderr_logger.log(stderr_log_level, line)
234237
stderr_lines.append(line)
235238

236239
stdout, _ = await asyncio.gather(process.stdout.read(), _stream())

services/apps/git_integration/src/crowdgit/services/vulnerability_scanner/vulnerability_scanner_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async def run(self, repo_id: str, repo_path: str, repo_url: str) -> None:
3636
output = await run_shell_command(
3737
[self.vulnerability_scanner_executable, repo_path, repo_url],
3838
stderr_logger=self.logger,
39+
stderr_log_level="DEBUG",
3940
)
4041
except Exception as e:
4142
self.logger.warning(f"Scanner failed for {repo_url}: {e}")
@@ -54,6 +55,7 @@ async def run(self, repo_id: str, repo_path: str, repo_url: str) -> None:
5455
"--no-transitive",
5556
],
5657
stderr_logger=self.logger,
58+
stderr_log_level="DEBUG",
5759
)
5860
except Exception as retry_err:
5961
self.logger.error(f"Retry also failed for {repo_url}: {retry_err}")
@@ -68,7 +70,7 @@ async def run(self, repo_id: str, repo_path: str, repo_url: str) -> None:
6870
output = None
6971

7072
if output is not None:
71-
self.logger.info(f"Vulnerability scanner output: {output}")
73+
self.logger.debug(f"Vulnerability scanner output: {output}")
7274
try:
7375
json_output = json.loads(output)
7476
except json.JSONDecodeError as e:

0 commit comments

Comments
 (0)