Skip to content

Commit 97bd2ab

Browse files
authored
Merge pull request #138 from intelowlproject/develop
4.1.3
2 parents 7961081 + 012ed48 commit 97bd2ab

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

.github/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [4.1.2](https://github.com/intelowlproject/pyintelowl/releases/tag/4.1.3)
4+
5+
- Library: `IntelOwl.ask_analysis_availability` now accepts an argument `minutes_ago`. Use to specify number of minutes to go back when searching for a previous analysis.
6+
- CLI: `-m/--check-minutes-ago` flag in `analyse`.
7+
38
## [4.1.2](https://github.com/intelowlproject/pyintelowl/releases/tag/4.1.2)
49

510
- Fix `runtime_configuration` bug in `IntelOwl.send_observable_analysis_request`

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import sys
1515

16-
VERSION = "4.1.2"
16+
VERSION = "4.1.3"
1717
GITHUB_URL = "https://github.com/intelowlproject/pyintelowl"
1818

1919
sys.path.append(os.path.abspath("../"))
@@ -22,7 +22,7 @@
2222
# -- Project information -----------------------------------------------------
2323

2424
project = "PyIntelOwl"
25-
copyright = "2020, Matteo Lodi"
25+
copyright = "2021, Matteo Lodi"
2626
author = "Matteo Lodi"
2727

2828
# The full version, including alpha/beta/rc tags

pyintelowl/cli/analyse.py

+13
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,22 @@
5050
3. 'force_new': force new analysis
5151
""",
5252
),
53+
click.option(
54+
"-m",
55+
"--check-minutes-ago",
56+
type=int,
57+
default=None,
58+
help="Number of minutes ago to check for"
59+
" a previous analysis. Default infinity.",
60+
),
5361
click.option(
5462
"-r",
5563
"--runtime-config",
5664
help="Path to JSON file which contains runtime_configuration.",
5765
type=click.Path(exists=True, resolve_path=True),
5866
),
5967
click.option(
68+
"-p",
6069
"--poll",
6170
"should_poll",
6271
is_flag=True,
@@ -84,6 +93,7 @@ def observable(
8493
tags_list: str,
8594
tlp: str,
8695
check,
96+
check_minutes_ago: int,
8797
runtime_config,
8898
should_poll: bool,
8999
):
@@ -105,6 +115,7 @@ def observable(
105115
runtime_config,
106116
tags_labels,
107117
should_poll,
118+
check_minutes_ago,
108119
)
109120
except IntelOwlClientException as e:
110121
ctx.obj.logger.fatal(str(e))
@@ -122,6 +133,7 @@ def file(
122133
tags_list: str,
123134
tlp: str,
124135
check,
136+
check_minutes_ago: int,
125137
runtime_config,
126138
should_poll: bool,
127139
):
@@ -143,6 +155,7 @@ def file(
143155
runtime_config,
144156
tags_labels,
145157
should_poll,
158+
check_minutes_ago,
146159
)
147160
except IntelOwlClientException as e:
148161
ctx.obj.logger.fatal(str(e))

pyintelowl/pyintelowl.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def ask_analysis_availability(
9999
md5: str,
100100
analyzers: List[str] = None,
101101
check_reported_analysis_too: bool = False,
102+
minutes_ago: int = None,
102103
) -> Dict:
103104
"""Search for already available analysis.\n
104105
Endpoint: ``/api/ask_analysis_availability``
@@ -110,6 +111,9 @@ def ask_analysis_availability(
110111
Defaults to `None` meaning automatically select all configured analyzers.
111112
check_reported_analysis_too (bool, optional):
112113
Check against all existing jobs. Defaults to ``False``.
114+
minutes_ago (int, optional):
115+
number of minutes to check back for analysis.
116+
Default is None so the check does not have any time limits.
113117
114118
Raises:
115119
IntelOwlClientException: on client/HTTP error
@@ -122,6 +126,8 @@ def ask_analysis_availability(
122126
data = {"md5": md5, "analyzers": analyzers}
123127
if not check_reported_analysis_too:
124128
data["running_only"] = True
129+
if minutes_ago:
130+
data["minutes_ago"] = int(minutes_ago)
125131
url = self.instance + "/api/ask_analysis_availability"
126132
response = self.__make_request("POST", url=url, data=data)
127133
answer = response.json()
@@ -503,6 +509,7 @@ def _new_analysis_cli(
503509
runtime_configuration: Dict = None,
504510
tags_labels: List[str] = None,
505511
should_poll: bool = False,
512+
minutes_ago: int = None,
506513
) -> None:
507514
"""
508515
For internal use by the pyintelowl CLI.
@@ -526,8 +533,12 @@ def _new_analysis_cli(
526533
# 1st step: ask analysis availability
527534
if check != "force-new":
528535
md5 = self.get_md5(obj, type_=type_)
536+
529537
resp = self.ask_analysis_availability(
530-
md5, analyzers_list, True if check == "reported" else False
538+
md5,
539+
analyzers_list,
540+
True if check == "reported" else False,
541+
minutes_ago,
531542
)
532543
status, job_id = resp.get("status", None), resp.get("job_id", None)
533544
if status != "not_available":

pyintelowl/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.1.2"
1+
__version__ = "4.1.3"

0 commit comments

Comments
 (0)