Skip to content

Commit 5b53d74

Browse files
committed
Configure setup as modern installable package.
- Modernize setup to an installable package supporting pyproject.toml, Hatch and easy pipx installation. Command can now be called from a global entry point called `inquestlabs`. - Inline dependencies in the package spec and deprecate requirements.txt. - Unify version output from package metadata. - Update documentation in README.md. Tests: 88 passed in 1.31s
1 parent c43eb73 commit 5b53d74

File tree

5 files changed

+115
-33
lines changed

5 files changed

+115
-33
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ python:
33
- "3.9"
44

55
install:
6-
- "pip install -r requirements.txt"
6+
- "pip install ."
77
- "pip install pytest pytest-mock coverage requests-mock"
88
script:
99
- coverage run -m pytest

README.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,39 @@
44
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/9da8a5cde7c34c849c73969ac3281be8)](https://www.codacy.com/gh/InQuest/python-inquestlabs/dashboard?utm_source=github.com&utm_medium=referral&utm_content=InQuest/python-inquestlabs&utm_campaign=Badge_Coverage)
55

66
# python-inquestlabs
7-
A Pythonic interface and command line tool for interacting with the [InQuest Labs](https://labs.inquest.net) API. Note that an API key is *not* required to interact with this API. An API key does provide the ability to increase their lookback, remove rate limitations, and download available samples. Users can sign-in via OAuth to generate API keys. There is no cost to sign-in. Authentication is supported via LinkedIn, Twitter, Google, and Github.
7+
A Pythonic interface and command line tool for interacting with the
8+
[InQuest Labs](https://labs.inquest.net) API. Note that an API key is *not*
9+
required to interact with this API. An API key does provide the ability to
10+
increase their lookback, remove rate limitations, and download available
11+
samples. Users can sign in via OAuth to generate API keys. There is no cost to
12+
sign in. Authentication is supported via LinkedIn, Twitter, Google, and
13+
Github.
814

9-
Searchable API documentation with multi-language snippets: https://labs.inquest.net/docs/
15+
Searchable API documentation with multi-language snippets:
16+
<https://labs.inquest.net/docs/>
1017

11-
OpenAPI (Swagger) specification: https://app.swaggerhub.com/apis-docs/InQuest.net/InQuestLabs/1.0
18+
OpenAPI (Swagger) specification:
19+
<https://app.swaggerhub.com/apis-docs/InQuest.net/InQuestLabs/1.0>
20+
21+
## Installation
22+
The recommended way to install python-inquestlabs for CLI use is using
23+
[pipx](https://pypa.github.io/pipx/). This installs the package and all
24+
dependencies in an isolated virtual environment that can be invoked easily.
25+
26+
pipx install inquestlabs
27+
28+
Alternately, or in cases where you want to use python-inquestlabs as a library,
29+
you can install it using [pip](https://pip.pypa.io/).
30+
31+
pip install inquestlabs
1232

1333
## InQuest Labs Command Line Driver
34+
To see the available command line tools and options, see the output of
35+
`inquestlabs --help`. It'll look something like this:
36+
1437
```
38+
InQuest Labs Command Line Driver
39+
1540
Usage:
1641
inquestlabs [options] dfi list
1742
inquestlabs [options] dfi details <sha256> [--attributes]
@@ -32,6 +57,9 @@ Usage:
3257
inquestlabs [options] yara hexcase <instring>
3358
inquestlabs [options] yara uint <instring> [--offset=<offset>] [--hex]
3459
inquestlabs [options] yara widere <regex> [(--big-endian|--little-endian)]
60+
inquestlabs [options] lookup ip <ioc>
61+
inquestlabs [options] lookup domain <ioc>
62+
inquestlabs [options] report <ioc>
3563
inquestlabs [options] stats
3664
inquestlabs [options] setup <apikey>
3765
inquestlabs [options] trystero list-days
@@ -51,6 +79,7 @@ Options:
5179
--little-endian Toggle little endian.
5280
--offset=<offset> Specify an offset other than 0 for the trigger.
5381
--proxy=<proxy> Intermediate proxy
82+
--timeout=<timeout> Maximum amount of time to wait for IOC report.
5483
--verbose=<level> Verbosity level, outputs to stderr [default: 0].
5584
--version Show version.
5685
```
@@ -59,29 +88,45 @@ Options:
5988

6089
The following third-party projects integrate with InQuest Labs:
6190

62-
* [MalOverview](https://github.com/alexandreborges/malwoverview) from [@ale_sp_brazil](https://twitter.com/ale_sp_brazil).
63-
* [EML Analyzer](https://eml-analyzer.herokuapp.com/) from [@ninoseki](https://twitter.com/ninoseki).
64-
* ["Spoken" IOCs](https://github.com/safernandez666/IOC) from [@safernandez666](https://twitter.com/safernandez666).
65-
* [Axial R4PTOR](https://ax1al.com/projects/r4pt0r) from [@AXI4L](https://twitter.com/AXI4L).
91+
* [MalOverview](https://github.com/alexandreborges/malwoverview) from
92+
[@ale_sp_brazil](https://twitter.com/ale_sp_brazil).
93+
* [EML Analyzer](https://eml-analyzer.herokuapp.com/) from
94+
[@ninoseki](https://twitter.com/ninoseki).
95+
* ["Spoken" IOCs](https://github.com/safernandez666/IOC) from
96+
[@safernandez666](https://twitter.com/safernandez666).
97+
* [Axial R4PTOR](https://ax1al.com/projects/r4pt0r) from
98+
[@AXI4L](https://twitter.com/AXI4L).
6699

67100
Get in touch or issue a pull-request to get your project listed.
68101

69102
## Testing
70103

71-
Use pytest to test each case (or individually by specifying which file to test):
104+
Use pytest to test each case (or individually by specifying which file to
105+
test):
72106

73107
`pytest tests/*`
74108

75109
## The Trystero Project
76110

77-
The vast majority of attacks (>90%) are email borne. The "Trystero Project" is our code name for an experiment that we're actively conducting to measure the security efficacy of the two largest mail providers, Google and Microsoft, against real-world emerging malware. The basic idea is this... let's take real-world threats daily and loop it through the two most popular cloud email providers, Google and Microsoft. We'll monitor which samples make it to the inbox and compare the results over the time. You can rea more, view graphs, explore data, and compare results at [InQuest Labs: Trystero Project](https://labs.inquest.net/trystero). If you're curious to explore the testing corpus further, see the following two command line options:
111+
The vast majority of attacks (>90%) are email-borne. The "Trystero Project" is
112+
our code name for an experiment that we're actively conducting to measure the
113+
security efficacy of the two largest mail providers, Google and Microsoft,
114+
against real-world emerging malware. The basic idea is this... let's take
115+
real-world threats daily and loop it through the two most popular cloud email
116+
providers, Google and Microsoft. We'll monitor which samples make it to the
117+
inbox and compare the results over the time. You can read more, view graphs,
118+
explore data, and compare results at [InQuest Labs: Trystero
119+
Project](https://labs.inquest.net/trystero). If you're curious to explore the
120+
testing corpus further, see the following two command line options:
78121

79122
### List Trystero Days
80123

81-
For a list of days we have ran the Trystero Project and the number of samples harvested for each day. Note that `first_record` denotes the earliest record (2020-08-09):
124+
For a list of days we have ran the Trystero Project and the number of samples
125+
harvested for each day. Note that `first_record` denotes the earliest record
126+
(2020-08-09):
82127

83128
```
84-
$ python inquestlabs.py trystero list-days | jq .
129+
$ inquestlabs trystero list-days | jq .
85130
{
86131
"2021-01-08": 27,
87132
"2021-01-09": 26,
@@ -329,10 +374,13 @@ $ python inquestlabs.py trystero list-days | jq .
329374

330375
### List Trystero Samples
331376

332-
You can receive further details about each sample from any given daily corpus. Information included is similar to the output of `dfi list` with the addition of `bypasses` that denotes which provider was bypassed and `available_on_labs` which states the sample can be seen on labs.inquest.net:
377+
You can receive further details about each sample from any given daily corpus.
378+
Information included is similar to the output of `dfi list` with the addition
379+
of `bypasses` that denotes which provider was bypassed and `available_on_labs`
380+
which states the sample can be seen on labs.inquest.net:
333381

334382
```
335-
$ python inquestlabs.py trystero list-samples 2021-06-29 | jq .
383+
$ inquestlabs trystero list-samples 2021-06-29 | jq .
336384
[
337385
{
338386
"analysis_completed": true,

inquestlabs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@
7979
import sys
8080
import os
8181
import re
82+
from importlib.metadata import version
8283

83-
__version__ = 1.1
84+
# extract version from installed package metadata
85+
__application_name__ = "inquestlabs"
86+
__version__ = version(__application_name__)
87+
__full_version__ = f"{__application_name__} {__version__}"
8488

8589
VALID_CAT = ["ext", "hash", "ioc"]
8690
VALID_EXT = ["code", "context", "metadata", "ocr"]

pyproject.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[build-system]
2+
requires = ["hatchling", "wheel"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "inquestlabs"
7+
version = "1.2.1"
8+
license = {file = "LICENSE"}
9+
authors = [
10+
# XXX What email should be used here?
11+
{ name="InQuest", email="support@inquest.net" },
12+
]
13+
description = "A Pythonic interface and CLI tool for the InQuest Labs API"
14+
readme = "README.md"
15+
requires-python = ">=3.9"
16+
dependencies = [
17+
"attrs==22.1.0",
18+
"certifi==2022.9.24",
19+
"charset-normalizer==2.1.1",
20+
"coverage==6.5.0",
21+
"docopt==0.6.2",
22+
"idna==3.4",
23+
"iniconfig==1.1.1",
24+
"packaging==21.3",
25+
"pluggy==1.0.0",
26+
"py==1.11.0",
27+
"pyparsing==3.0.9",
28+
"pytest==7.1.3",
29+
"pytest-mock==3.9.0",
30+
"requests==2.28.1",
31+
"requests-mock==1.10.0",
32+
"six==1.16.0",
33+
"tomli==2.0.1",
34+
"urllib3==1.26.12",
35+
]
36+
classifiers = [
37+
"Programming Language :: Python :: 3",
38+
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
39+
"Operating System :: OS Independent",
40+
]
41+
42+
[project.scripts]
43+
inquestlabs = "inquestlabs:main"
44+
45+
[project.urls]
46+
"Homepage" = "https://labs.inquest.net/"
47+
"Repository" = "https://github.com/InQuest/python-inquestlabs"
48+
"Bug Tracker" = "https://github.com/InQuest/python-inquestlabs/issues"

requirements.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)