|
8 | 8 | from codegate.pipeline.base import AlertSeverity, CodeSnippet, PipelineContext
|
9 | 9 | from codegate.pipeline.extract_snippets.extract_snippets import extract_snippets
|
10 | 10 | from codegate.pipeline.output import OutputPipelineContext, OutputPipelineStep
|
11 |
| -from codegate.pipeline.suspicious_commands.suspicious_commands import SuspiciousCommands |
12 | 11 | from codegate.storage import StorageEngine
|
13 | 12 | from codegate.utils.package_extractor import PackageExtractor
|
14 | 13 |
|
@@ -43,23 +42,13 @@ def _create_chunk(self, original_chunk: ModelResponse, content: str) -> ModelRes
|
43 | 42 |
|
44 | 43 | async def _snippet_comment(self, snippet: CodeSnippet, context: PipelineContext) -> str:
|
45 | 44 | """Create a comment for a snippet"""
|
46 |
| - comment = "" |
47 |
| - sc = SuspiciousCommands.get_instance() |
48 |
| - class_, prob = await sc.classify_phrase(snippet.code) |
49 |
| - if class_ == 1: |
50 |
| - liklihood = "possibly" |
51 |
| - language = "code" |
52 |
| - if prob > 0.9: |
53 |
| - liklihood = "likely" |
54 |
| - if snippet.language is not None: |
55 |
| - language = snippet.language |
56 |
| - comment = f"{comment}\n\n🛡️ CodeGate: The {language} supplied is {liklihood} unsafe. Please check carefully!\n\n" # noqa: E501 |
57 | 45 |
|
| 46 | + # extract imported libs |
58 | 47 | snippet.libraries = PackageExtractor.extract_packages(snippet.code, snippet.language)
|
59 | 48 |
|
60 | 49 | # If no libraries are found, just return empty comment
|
61 | 50 | if len(snippet.libraries) == 0:
|
62 |
| - return comment |
| 51 | + return "" |
63 | 52 |
|
64 | 53 | # Check if any of the snippet libraries is a bad package
|
65 | 54 | storage_engine = StorageEngine()
|
@@ -93,7 +82,7 @@ async def _snippet_comment(self, snippet: CodeSnippet, context: PipelineContext)
|
93 | 82 | )
|
94 | 83 |
|
95 | 84 | # Add a codegate warning for the bad packages found in the snippet
|
96 |
| - comment = f"{comment}\n\nWarning: CodeGate detected one or more potentially malicious or \ |
| 85 | + comment = f"\n\nWarning: CodeGate detected one or more potentially malicious or \ |
97 | 86 | archived packages: {libobjects_text}\n"
|
98 | 87 | comment += "\n### 🚨 Warnings\n" + "\n".join(warnings) + "\n"
|
99 | 88 |
|
|
0 commit comments