Skip to content

Commit

Permalink
Merge pull request #27 from eljeffeg/master
Browse files Browse the repository at this point in the history
verify_certificate
  • Loading branch information
cccs-kevin authored Sep 2, 2022
2 parents e675ecd + 32df855 commit 21537eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Once MetaDefender Core has been installed and activated with your license, the f
* **base_url**: The URL(s) of the MetaDefender deployment(s)
* If you have a **single** MetaDefender Core deployment, set the service variable to **str** type and enter the URL of your MetaDefender Core deployment
* If you have **multiple** MetaDefender Core deployments, set the service variable to **list** type and enter the URLs of your MetaDefender Core deployments separated by a comma
* **verify_certificate**: Setting to False will ignore verifying the SSL certificate
* **md_version**: Version of MetaDefender you're connecting to (3 or 4)
* **md_timeout**: Maximum amount of time to wait while connecting to the MetaDefender server
* **max_md_scan_time**: Maximum amount of time to wait for scan results before the MetaDefender server is put on a brief timeout (only applicable when multiple MetaDefender deployments are used)
Expand Down
7 changes: 4 additions & 3 deletions metadefender.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, config: Optional[Dict[str, Any]] = None) -> None:
self.kw_score_revision_map: Optional[Dict[str, int]] = None
self.sig_score_revision_map: Optional[Dict[str, Any]] = None
self.safelist_match: List[str] = []
self.verify = self.config.get("verify_certificate", True)
api_key = self.config.get("api_key")
if api_key:
self.headers = {"apikey": api_key}
Expand Down Expand Up @@ -173,7 +174,7 @@ def _get_version_map(self, node: str) -> None:

try:
self.log.debug(f"_get_version_map: GET {url}")
r = self.session.get(url=url, timeout=self.timeout)
r = self.session.get(url=url, timeout=self.timeout, verify=self.verify)
engines = r.json()

for engine in engines:
Expand Down Expand Up @@ -268,7 +269,7 @@ def get_scan_results_by_data_id(self, data_id: str) -> Response:

try:
self.log.debug(f"get_scan_results_by_data_id: GET {url}")
return self.session.get(url=url, headers=self.headers, timeout=self.timeout)
return self.session.get(url=url, headers=self.headers, timeout=self.timeout, verify=self.verify)
except exceptions.Timeout:
self.new_node(force=True, reset_queue=True)
raise Exception(f"Node ({self.current_node}) timed out after {self.timeout}s "
Expand Down Expand Up @@ -332,7 +333,7 @@ def scan_file(self, filename: str) -> Dict[str, Any]:

try:
self.log.debug(f"scan_file: POST {url}")
r = self.session.post(url=url, data=data, headers=self.headers, timeout=self.timeout)
r = self.session.post(url=url, data=data, headers=self.headers, timeout=self.timeout, verify=self.verify)
except exceptions.Timeout:
self.new_node(force=True, reset_queue=True)
raise Exception(f"Node ({self.current_node}) timed out after {self.timeout}s "
Expand Down
1 change: 1 addition & 0 deletions service_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ licence_count: 0
config:
api_key: ""
base_url: 'http://localhost:8008/'
verify_certificate: true
md_version: 4
md_timeout: 40
min_node_time: 60
Expand Down

0 comments on commit 21537eb

Please sign in to comment.