[ANY.RUN] Migrate to the ANY.RUN SDK, update actions, add new actions#3830
[ANY.RUN] Migrate to the ANY.RUN SDK, update actions, add new actions#3830semayellow wants to merge 3 commits intorapid7:any_run-3.0.0-releasefrom
Conversation
⛔ Snyk checks have failed. 2 issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| def run(self, params={}): | ||
| try: | ||
| with SandboxConnector.android(self.connection.sandbox_api_key, integration=Config.VERSION) as connector: | ||
| analysis_uuid = connector.run_url_analysis(**params) |
There was a problem hiding this comment.
In that case, I am not sure if unpacking the entire params dictionary directly into the SDK method is a good idea. If there are any further changes to the naming of the fields in the Any.Run SDK, we will need to update the plugin schema structure.
I suggest binding the inputs to variables first, and then passing them one by one to the 'run_url_analysis' method.
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
file_content = params.pop(Input.FILE_CONTENT, "")
filename = params.pop(Input.FILENAME, "")
...
# END INPUT BINDING - DO NOT REMOVE| @auto_instrument | ||
| def run(self, params={}): | ||
| # START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION | ||
| analysis_uuid = params.get(Input.ANALYSIS_UUID) |
There was a problem hiding this comment.
| analysis_uuid = params.get(Input.ANALYSIS_UUID) | |
| analysis_uuid = params.get(Input.ANALYSIS_UUID, "") |
| def run(self, params={}): | ||
| try: | ||
| with BaseSandboxConnector(self.connection.sandbox_api_key, integration=Config.VERSION) as connector: | ||
| history_tasks = connector.get_analysis_history(**params) |
There was a problem hiding this comment.
I would say same as previous comment related to unpacking dictionary directly to SDK method.
I suggest binding the inputs to variables first, and then passing them one by one to the run_url_analysis method.
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
...
# END INPUT BINDING - DO NOT REMOVE| report_format = params.get(Input.FORMAT) | ||
| analysis_uuid = params.get(Input.ANALYSIS_UUID) |
There was a problem hiding this comment.
| report_format = params.get(Input.FORMAT) | |
| analysis_uuid = params.get(Input.ANALYSIS_UUID) | |
| report_format = params.get(Input.FORMAT, "") | |
| analysis_uuid = params.get(Input.ANALYSIS_UUID, "") |
| @auto_instrument | ||
| def run(self, params={}): | ||
| # START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION | ||
| analysis_uuid = params.get(Input.ANALYSIS_UUID) |
There was a problem hiding this comment.
| analysis_uuid = params.get(Input.ANALYSIS_UUID) | |
| analysis_uuid = params.get(Input.ANALYSIS_UUID, "") |
| opt_network_geo: | ||
| title: Network Geo | ||
| description: TOR geo location option | ||
| type: string | ||
| required: false | ||
| default: 'fastest' | ||
| example: 'US' |
| opt_network_residential_proxy_geo: | ||
| title: Residential Proxy Geo | ||
| description: Residential Proxy Geo option | ||
| type: string | ||
| required: false | ||
| default: 'fastest' | ||
| example: 'US' |
| example: 'url' | ||
| entity_value: | ||
| title: Entity Value | ||
| description: URL (Size range 2-256) or Hash (SHA256, SAH1, MD5) or Domain or IP |
There was a problem hiding this comment.
| description: URL (Size range 2-256) or Hash (SHA256, SAH1, MD5) or Domain or IP | |
| description: URL (Size range 2-256) or Hash (SHA256, SHA1, MD5) or Domain or IP |
| lookup_url = ( | ||
| "https://intelligence.any.run/analysis/lookup#{%22query%22:%22" | ||
| + query.replace('"', "%5C%22").replace(" ", "%20") | ||
| + "%22,%22dateRange%22:180}" | ||
| ) |
There was a problem hiding this comment.
This is fine and it would work, but I think it could be even more readable with using quote from urllib3 and json. It could be something like:
import json
from urllib.parse import quote
...
payload = {"query": query, "dateRange": 180}
lookup_url = f"https://intelligence.any.run/analysis/lookup#{quote(json.dumps(payload))}"There was a problem hiding this comment.
Please include error handling with PluginException in action tests.
🎫 Ticket
🧩 Type of Change
🧠 Background & Motivation
✨ What Changed
Removed actions
Added new actions
ANY.RUN Sandbox:
ANY.RUN TI Lookup:
Updated connecton
To support API key processing for both services
Updated unit-test and documentation
🧪 Testing