Skip to content

Commit

Permalink
INFOBLOX_THREAT_DEFENSE:: Refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
NLAdvens committed Jan 24, 2025
1 parent b367d7b commit f49547a
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
__doc__ = 'INFOBLOX THREAT DEFENSE API'
__parser__ = 'INFOBLOX_THREAT_DEFENSE'

import json
from json import dumps as json_dumps
import logging

import dateutil
import requests
from requests import Session as requests_session

from datetime import timedelta
from django.utils import timezone
Expand Down Expand Up @@ -59,7 +58,7 @@ def __init__(self, data):
def _connect(self):
try:
if self.session is None:
self.session = requests.Session()
self.session = requests_session()

self.session.headers.update(self.HEADERS)
self.session.headers.update({"AUTHORIZATION": f"TOKEN {self.infoblox_threat_defense_token}"})
Expand Down Expand Up @@ -118,8 +117,8 @@ def test(self):
"error": str(e)
}

def format_log(self, log, since, to):
return json.dumps(log)
def format_log(self, log):
return json_dumps(log)

def execute(self):
since = self.last_api_call or (timezone.now() - timedelta(days=30))
Expand All @@ -138,10 +137,7 @@ def execute(self):

offset += len(logs)

# Downloading may take some while, so refresh token in Redis
self.update_lock()

self.write_to_file([self.format_log(l, since, to) for l in logs])
self.write_to_file([self.format_log(l) for l in logs])

Check failure on line 140 in vulture_os/toolkit/api_parser/infoblox_threat_defense/infoblox_threat_defense.py

View workflow job for this annotation

GitHub Actions / check

Ruff (E741)

vulture_os/toolkit/api_parser/infoblox_threat_defense/infoblox_threat_defense.py:140:56: E741 Ambiguous variable name: `l`

# Writting may take some while, so refresh token in Redis
self.update_lock()
Expand Down

0 comments on commit f49547a

Please sign in to comment.