Skip to content

Commit

Permalink
[Marketplace Contribution] VMRay Analyzer - Content Pack Update (#30293)
Browse files Browse the repository at this point in the history
* [Marketplace Contribution] VMRay Analyzer - Content Pack Update (#28872)

* "contribution update to pack "VMRay Analyzer""

* Fixed several issues / added docs

* Update VMRay.yml

Added  Descriptions to command

* Changed as requested

* fix conflicts

* conflict with docker image

* Added documentation for commands

* fix the readme

* fix yml

* format

* fix validation

---------

Co-authored-by: Konrad <15833518+Drizzt-IT@users.noreply.github.com>
Co-authored-by: Menachem Weinfeld <90556466+mmhw@users.noreply.github.com>
Co-authored-by: Yehuda <yrosenberg@paloaltonetworks.com>

* add a period

* fix RN

* Apply suggestions from Shirley

Co-authored-by: ShirleyDenkberg <62508050+ShirleyDenkberg@users.noreply.github.com>

* flake 8

* docker

* add outputs

* adding pragma no cover' since the new functions are straightforward and don't need test

* moving the no cover to the new functions instead main

* flake 8

---------

Co-authored-by: xsoar-bot <67315154+xsoar-bot@users.noreply.github.com>
Co-authored-by: Konrad <15833518+Drizzt-IT@users.noreply.github.com>
Co-authored-by: Menachem Weinfeld <90556466+mmhw@users.noreply.github.com>
Co-authored-by: Yehuda <yrosenberg@paloaltonetworks.com>
Co-authored-by: Yehuda Rosenberg <90599084+RosenbergYehuda@users.noreply.github.com>
Co-authored-by: ShirleyDenkberg <62508050+ShirleyDenkberg@users.noreply.github.com>
  • Loading branch information
7 people committed Oct 19, 2023
1 parent d182ae8 commit 04f3760
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 26 deletions.
99 changes: 99 additions & 0 deletions Packs/VMRay/Integrations/VMRay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ After you successfully execute a command, a DBot message appears in the War Room
- [vmray-get-iocs](#vmray-get-iocs): Get IOCs for a sample
- [vmray-get-job-by-id](#vmray-get-job-by-id): Get information for a job
- [vmray-get-summary](#vmray-get-summary): Download Summary JSON v2 for an analysis
- [vmray-get-license-usage-verdicts](#vmray-get-license-usage-verdicts): Get the used quota of verdicts
- [vmray-get-license-usage-reports](#vmray-get-license-usage-reports): Get the used quota of reports


### vmray-upload-sample
Expand All @@ -69,6 +71,7 @@ Submits a sample to VMRay for analysis.
| max_jobs | Maximum number of jobs to create (number). Default is 1. | Optional |
| tags | A CSV list of tags to add to the sample. | Optional |
| reanalyze | Deprecated. Analyze even if analyses already exist. To control analysis caching, use the API Key settings instead, which are available via the Analysis Settings page, in the VMRay Web Interface. Possible values are: true, false. | Optional |
| net_scheme_name | The network scheme to use. | Optional |

#### Context Output

Expand Down Expand Up @@ -1142,3 +1145,99 @@ Retrieves screenshots taken during a specific dynamic analysis. The screenshots
]
}
```


### vmray-get-license-usage-verdicts
***
Gets the usage of verdicts from VMRay.


#### Base Command

`vmray-get-license-usage-verdicts`
#### Input

There is no input for this command.


#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| VMRay.VerdictQuota.PeriodEndDate | string | License end date. |
| VMRay.VerdictQuota.VerdictQuota | number | Total number of available verdicts (per month). |
| VMRay.VerdictQuota.VerdictRemaining | number | Remaining number of verdicts (per month). |
| VMRay.VerdictQuota.VerdictUsage | number | Percentages used. |


#### Command Example

```vmray-get-license-usage-verdicts```

#### Context Example

```json
{
"VMRay.VerdictQuota": {
"PeriodEndDate": "2024-02-03 14:12 (UTC+1)",
"VerdictQuota": 100,
"VerdictRemaining": 90,
"VerdictUsage": 10
}
}
```

#### Human Readable Output

| VerdictQuota | 100 |
| VerdictRemaining | 90 |
| VerdictUsage | 10.0 |
| PeriodEndDate | 2024-02-03 14:12 (UTC+1) |


### vmray-get-license-usage-reports
***
Gets the usage of reports from VMRay.


#### Base Command

`vmray-get-license-usage-reports`
#### Input

There is no input for this command.


#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| VMRay.ReportQuota.PeriodEndDate | string | License end date. |
| VMRay.ReportQuota.VerdictQuota | number | Total number of available reports (per month). |
| VMRay.ReportQuota.VerdictRemaining | number | Remaining number of reports (per month). |
| VMRay.ReportQuota.VerdictUsage | number | Percentages used. |

#### Context Example

```json
{
"VMRay.ReportsQuota": {
"PeriodEndDate": "2024-02-03 14:12 (UTC+1)",
"ReportQuota": 100,
"ReportRemaining": 90,
"ReportUsage": 10
}
}
```

#### Command Example
```
vmray-get-license-usage-reports
```

#### Human Readable Output

| ReportQuota | 100 |
| ReportRemaining | 90 |
| ReportUsage | 10.0 |
| PeriodEndDate | 2024-02-03 14:12 (UTC+1) |
70 changes: 69 additions & 1 deletion Packs/VMRay/Integrations/VMRay/VMRay.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import io
import os
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
import random
import time
import urllib3

from zipfile import ZipFile

import requests
from CommonServerPython import *

''' GLOBAL PARAMS '''
API_KEY = demisto.params().get('api_key') or demisto.params().get('credentials', {}).get('password')
Expand Down Expand Up @@ -349,6 +350,7 @@ def build_upload_params():
shareable = demisto.args().get('shareable')
max_jobs = demisto.args().get('max_jobs')
tags = demisto.args().get('tags')
net_scheme_name = demisto.args().get('net_scheme_name')

params = {}
if doc_pass:
Expand All @@ -367,6 +369,8 @@ def build_upload_params():
raise ValueError('max_jobs arguments isn\'t a number')
if tags:
params['tags'] = tags
if net_scheme_name:
params['user_config'] = "{\"net_scheme_name\": \"" + str(net_scheme_name) + "\"}"
return params


Expand Down Expand Up @@ -1393,6 +1397,66 @@ def get_screenshots_command():
return_results(file_results)


def vmray_get_license_usage_verdicts_command(): # pragma: no cover
"""
Returns:
dict: response
"""
suffix = 'billing_info'
raw_response = http_request('GET', suffix)
data = raw_response.get('data')

entry = dict()
entry['VerdictsQuota'] = data.get('verdict_quota')
entry['VerdictsRemaining'] = data.get('verdict_remaining')
entry['VerdictsUsage'] = round((100 / float(data.get('verdict_quota')))
* (float(data.get('verdict_quota')) - float(data.get('verdict_remaining'))), 2)
entry['PeriodEndDate'] = data.get('end_date')

markdown = tableToMarkdown('VMRay Verdicts Quota Information', entry, headers=[
'VerdictsQuota', 'VerdictsRemaining', 'VerdictsUsage', 'PeriodEndDate'])

results = CommandResults(
readable_output=markdown,
outputs_prefix='VMRay.VerdicsQuota',
outputs_key_field='PeriodEndDate',
outputs=entry
)

return_results(results)


def vmray_get_license_usage_reports_command(): # pragma: no cover
"""
Returns:
dict: response
"""
suffix = 'billing_info'
raw_response = http_request('GET', suffix)
data = raw_response.get('data')

entry = dict()
entry['ReportQuota'] = data.get('report_quota')
entry['ReportRemaining'] = data.get('report_remaining')
entry['ReportUsage'] = round((100 / float(data.get('report_quota')))
* (float(data.get('report_quota')) - float(data.get('report_remaining'))), 2)
entry['PeriodEndDate'] = data.get('end_date')

markdown = tableToMarkdown('VMRay Reports Quota Information', entry, headers=[
'ReportQuota', 'ReportRemaining', 'ReportUsage', 'PeriodEndDate'])

results = CommandResults(
readable_output=markdown,
outputs_prefix='VMRay.ReportsQuota',
outputs_key_field='PeriodEndDate',
outputs=entry
)

return_results(results)


def main():
try:
command = demisto.command()
Expand Down Expand Up @@ -1429,6 +1493,10 @@ def main():
get_summary_command()
elif command == 'vmray-get-screenshots':
get_screenshots_command()
elif command == 'vmray-get-license-usage-verdicts':
vmray_get_license_usage_verdicts_command()
elif command == 'vmray-get-license-usage-reports':
vmray_get_license_usage_reports_command()
except Exception as exc:
return_error(f"Failed to execute `{demisto.command()}` command. Error: {str(exc)}")

Expand Down

0 comments on commit 04f3760

Please sign in to comment.