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

Revert "Initial suspicious commands (#917)" #930

Merged
merged 1 commit into from
Feb 5, 2025
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
659 changes: 37 additions & 622 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ sqlite-vec-sl-tmp = "==0.0.4"
greenlet = "==3.1.1"
cachetools = "==5.5.1"
legacy-cgi = "==2.6.2"
torch = "==2.6.0"
pandas = "==2.2.3"

[tool.poetry.group.dev.dependencies]
pytest = "==8.3.4"
Expand Down
17 changes: 3 additions & 14 deletions src/codegate/pipeline/extract_snippets/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from codegate.pipeline.base import AlertSeverity, CodeSnippet, PipelineContext
from codegate.pipeline.extract_snippets.extract_snippets import extract_snippets
from codegate.pipeline.output import OutputPipelineContext, OutputPipelineStep
from codegate.pipeline.suspicious_commands.suspicious_commands import SuspiciousCommands
from codegate.storage import StorageEngine
from codegate.utils.package_extractor import PackageExtractor

Expand Down Expand Up @@ -43,23 +42,13 @@ def _create_chunk(self, original_chunk: ModelResponse, content: str) -> ModelRes

async def _snippet_comment(self, snippet: CodeSnippet, context: PipelineContext) -> str:
"""Create a comment for a snippet"""
comment = ""
sc = SuspiciousCommands.get_instance()
class_, prob = await sc.classify_phrase(snippet.code)
if class_ == 1:
liklihood = "possibly"
language = "code"
if prob > 0.9:
liklihood = "likely"
if snippet.language is not None:
language = snippet.language
comment = f"{comment}\n\n🛡️ CodeGate: The {language} supplied is {liklihood} unsafe. Please check carefully!\n\n" # noqa: E501

# extract imported libs
snippet.libraries = PackageExtractor.extract_packages(snippet.code, snippet.language)

# If no libraries are found, just return empty comment
if len(snippet.libraries) == 0:
return comment
return ""

# Check if any of the snippet libraries is a bad package
storage_engine = StorageEngine()
Expand Down Expand Up @@ -93,7 +82,7 @@ async def _snippet_comment(self, snippet: CodeSnippet, context: PipelineContext)
)

# Add a codegate warning for the bad packages found in the snippet
comment = f"{comment}\n\nWarning: CodeGate detected one or more potentially malicious or \
comment = f"\n\nWarning: CodeGate detected one or more potentially malicious or \
archived packages: {libobjects_text}\n"
comment += "\n### 🚨 Warnings\n" + "\n".join(warnings) + "\n"

Expand Down
Binary file not shown.
189 changes: 0 additions & 189 deletions src/codegate/pipeline/suspicious_commands/suspicious_commands.py

This file was deleted.

34 changes: 0 additions & 34 deletions tests/data/suspicious_commands/benign_test_cmds.csv

This file was deleted.

18 changes: 0 additions & 18 deletions tests/data/suspicious_commands/malicious_test_cmds.csv

This file was deleted.

Loading