-
Notifications
You must be signed in to change notification settings - Fork 39
create GTI modules #1609
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
Open
CharlesLR-sekoia
wants to merge
8
commits into
develop
Choose a base branch
from
feat/new/gti_modules
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
create GTI modules #1609
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
104fe5e
create GTI modules
CharlesLR-sekoia 01e63e9
remove unecessary files
CharlesLR-sekoia b97c29c
fix issues
CharlesLR-sekoia b18c50a
fix manifest categories
CharlesLR-sekoia d7f35c8
remove validation pattern that enters in conflict with jinja patterning
CharlesLR-sekoia a5af46b
push gti vulnerability fix before deployment
CharlesLR-sekoia c957903
add proxy support
CharlesLR-sekoia ea47573
fix infinit loop on vulnerability report module
CharlesLR-sekoia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## Unreleased |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM python:3.11 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN pip install poetry | ||
|
|
||
| # Install dependencies | ||
| COPY poetry.lock pyproject.toml /app/ | ||
| RUN poetry config virtualenvs.create false && poetry install --only main | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN useradd -ms /bin/bash sekoiaio-runtime | ||
| USER sekoiaio-runtime | ||
|
|
||
| ENTRYPOINT [ "python", "./main.py" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # README | ||
|
|
||
| ## **Key Features** | ||
|
|
||
| ### 1. **Security Enhancements** | ||
| - API key loaded from environment variable (`VT_API_KEY`) | ||
| - Validation to prevent running with hardcoded keys | ||
| - Proper file existence checks before scanning | ||
|
|
||
| ### 2. **Error Handling** | ||
| - Try-catch blocks for all API calls | ||
| - Specific exception handling for `vt.APIError`, `FileNotFoundError`, `IOError` | ||
| - Detailed error logging and tracking | ||
| - Graceful degradation when tests fail | ||
|
|
||
| ### 3. **Official vt-py Library Usage** | ||
| - `client.scan_url()` for URL scanning | ||
| - `client.scan_file()` for file scanning | ||
| - `client.get_object()` for retrieving reports | ||
| - `client.get_json()` for raw JSON responses | ||
| - `client.iterator()` for paginated results | ||
| - Proper context manager usage (`with vt.Client()`) | ||
|
|
||
| ### 4. **Structured Results** | ||
| - `TestResult` dataclass for type-safe result storage | ||
| - JSON output with detailed success/error information | ||
| - Summary statistics at the end | ||
|
|
||
| ### 5. **Comprehensive Coverage** | ||
| All your required actions are covered: | ||
| - ✅ Scan File | ||
| - ✅ Get IOC Report (IP, URL, domain, file) | ||
| - ✅ Get Comments | ||
| - ✅ Get Vulnerability Associations | ||
| - ✅ Get File Sandbox Report | ||
| - ✅ Scan URL | ||
| - ✅ Get Passive DNS Data | ||
| - ✅ Get Vulnerability Report | ||
|
|
||
| ## **Usage** | ||
|
|
||
| ```bash | ||
| # Install vt-py | ||
| pip install vt-py | ||
|
|
||
| # Set your API key | ||
| export VT_API_KEY='your_actual_api_key' | ||
|
|
||
| # Run the script | ||
| python script.py | ||
sourcery-ai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Optional: test with a file | ||
| # Modify main() to include: tester.run_all_tests(test_file_path="your_file.png") | ||
| ``` | ||
|
|
||
| The script will generate `vt_test_results.json` with detailed results and print a summary to the console. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| { | ||
| "uuid": "a8e3b5f1-3f4a-4b2d-8f7e-1b2f6c9d5e11", | ||
| "name": "Get Comments", | ||
| "description": "Retrieve recent comments associated with a domain or IP from Google Threat Intelligence", | ||
| "docker_parameters": "get_comments", | ||
| "arguments": { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "type": "object", | ||
| "properties": { | ||
| "ip": { | ||
| "type": "string", | ||
| "description": "IP address to query (e.g., 8.8.8.8)", | ||
| "pattern": "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$" | ||
| }, | ||
| "domain": { | ||
| "type": "string", | ||
| "description": "Domain name to query (e.g., google.com)", | ||
| "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\\.[a-zA-Z]{2,}$" | ||
| }, | ||
| "url": { | ||
| "type": "string", | ||
| "description": "URL to query (e.g., https://example.com/path)", | ||
| "format": "uri" | ||
| }, | ||
| "file_hash": { | ||
| "type": "string", | ||
| "description": "File hash to query (MD5, SHA1, or SHA256)", | ||
| "pattern": "^[a-fA-F0-9]{32}$|^[a-fA-F0-9]{40}$|^[a-fA-F0-9]{64}$" | ||
| } | ||
| }, | ||
| "oneOf": [ | ||
| {"required": ["ip"]}, | ||
| {"required": ["domain"]}, | ||
| {"required": ["url"]}, | ||
| {"required": ["file_hash"]} | ||
| ] | ||
| }, | ||
| "results": { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "type": "object", | ||
| "title": "Get Comments Results", | ||
| "properties": { | ||
| "success": { "type": "boolean" }, | ||
| "data": { | ||
| "type": "object", | ||
| "description": "Container for the comments data", | ||
| "properties": { | ||
| "comments_count": { | ||
| "type": "integer", | ||
| "description": "Total number of comments retrieved" | ||
| }, | ||
| "entity": { | ||
| "type": "string", | ||
| "description": "The entity (domain, IP, URL, or file hash) that was queried" | ||
| }, | ||
| "comments": { | ||
| "type": "array", | ||
| "description": "Array of comment objects", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "type": { | ||
| "type": "string", | ||
| "description": "Type of the object (always 'comment')", | ||
| "enum": ["comment"] | ||
| }, | ||
| "id": { | ||
| "type": "string", | ||
| "description": "Unique identifier for the comment" | ||
| }, | ||
| "text": { | ||
| "type": "string", | ||
| "description": "The comment text content" | ||
| }, | ||
| "date": { | ||
| "type": ["integer", "string"], | ||
| "description": "Comment timestamp (Unix timestamp or ISO 8601 string)" | ||
| }, | ||
| "votes": { | ||
| "type": "object", | ||
| "description": "Vote statistics for the comment", | ||
| "properties": { | ||
| "positive": { | ||
| "type": "integer", | ||
| "description": "Number of positive votes" | ||
| }, | ||
| "negative": { | ||
| "type": "integer", | ||
| "description": "Number of negative votes" | ||
| } | ||
| }, | ||
| "required": ["positive", "negative"] | ||
| }, | ||
| "author": { | ||
| "type": ["string", "null"], | ||
| "description": "Username of the comment author (may be null for anonymous)" | ||
| } | ||
| }, | ||
| "required": ["text", "date", "votes"] | ||
| } | ||
| } | ||
| }, | ||
| "required": ["comments_count", "entity", "comments"] | ||
| } | ||
|
|
||
| } | ||
| }, | ||
| "slug": "get_comments_in_gti" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.