Skip to content

Commit ee1e3f5

Browse files
authored
Merge pull request #160 from DomainTools/IDEV-2061-implement-noh
IDEV-2061: Implement noh
2 parents dc1d5e0 + 8200e6f commit ee1e3f5

File tree

8 files changed

+78014
-1
lines changed

8 files changed

+78014
-1
lines changed

domaintools/api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,3 +1096,20 @@ def domaindiscovery(self, **kwargs) -> FeedsResults:
10961096
cls=FeedsResults,
10971097
**kwargs,
10981098
)
1099+
1100+
def noh(self, **kwargs) -> FeedsResults:
1101+
"""Returns back list of the newly observed hostnames feed"""
1102+
validate_feeds_parameters(kwargs)
1103+
endpoint = kwargs.pop("endpoint", Endpoint.FEED.value)
1104+
source = ENDPOINT_TO_SOURCE_MAP.get(endpoint).value
1105+
if endpoint == Endpoint.DOWNLOAD.value or kwargs.get("output_format", OutputFormat.JSONL.value) != OutputFormat.CSV.value:
1106+
# headers param is allowed only in Feed API and CSV format
1107+
kwargs.pop("headers", None)
1108+
1109+
return self._results(
1110+
f"newly-observed-hosts-feed-({source})",
1111+
f"v1/{endpoint}/noh/",
1112+
response_path=(),
1113+
cls=FeedsResults,
1114+
**kwargs,
1115+
)

domaintools/cli/commands/feeds.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,83 @@ def feeds_domaindiscovery(
314314
),
315315
):
316316
DTCLICommand.run(name=c.FEEDS_DOMAINDISCOVERY, params=ctx.params)
317+
318+
319+
@dt_cli.command(
320+
name=c.FEEDS_NOH,
321+
help=get_cli_helptext_by_name(command_name=c.FEEDS_NOH),
322+
)
323+
def feeds_noh(
324+
ctx: typer.Context,
325+
user: str = typer.Option(None, "-u", "--user", help="Domaintools API Username."),
326+
key: str = typer.Option(None, "-k", "--key", help="DomainTools API key"),
327+
creds_file: str = typer.Option(
328+
"~/.dtapi",
329+
"-c",
330+
"--credfile",
331+
help="Optional file with API username and API key, one per line.",
332+
),
333+
no_verify_ssl: bool = typer.Option(
334+
False,
335+
"--no-verify-ssl",
336+
help="Skip verification of SSL certificate when making HTTPs API calls",
337+
),
338+
no_sign_api_key: bool = typer.Option(
339+
False,
340+
"--no-sign-api-key",
341+
help="Skip signing of api key",
342+
),
343+
header_authentication: bool = typer.Option(
344+
True,
345+
"--no-header-auth",
346+
help="Don't use header authentication",
347+
),
348+
output_format: str = typer.Option(
349+
"jsonl",
350+
"-f",
351+
"--format",
352+
help=f"Output format in [{OutputFormat.JSONL.value}, {OutputFormat.CSV.value}]",
353+
callback=DTCLICommand.validate_feeds_format_input,
354+
),
355+
endpoint: str = typer.Option(
356+
Endpoint.FEED.value,
357+
"-e",
358+
"--endpoint",
359+
help=f"Valid endpoints: [{Endpoint.FEED.value}, {Endpoint.DOWNLOAD.value}]",
360+
callback=DTCLICommand.validate_endpoint_input,
361+
),
362+
sessionID: str = typer.Option(
363+
None,
364+
"--session-id",
365+
help="Unique identifier for the session",
366+
),
367+
after: str = typer.Option(
368+
None,
369+
"--after",
370+
help="Start of the time window, relative to the current time in seconds, for which data will be provided",
371+
callback=DTCLICommand.validate_after_or_before_input,
372+
),
373+
before: str = typer.Option(
374+
None,
375+
"--before",
376+
help="The end of the query window in seconds, relative to the current time, inclusive",
377+
callback=DTCLICommand.validate_after_or_before_input,
378+
),
379+
domain: str = typer.Option(
380+
None,
381+
"-d",
382+
"--domain",
383+
help="A string value used to filter feed results",
384+
),
385+
headers: bool = typer.Option(
386+
False,
387+
"--headers",
388+
help="Adds a header to the first line of response when text/csv is set in header parameters",
389+
),
390+
top: str = typer.Option(
391+
None,
392+
"--top",
393+
help="Number of results to return in the response payload. This is ignored in download endpoint",
394+
),
395+
):
396+
DTCLICommand.run(name=c.FEEDS_NOH, params=ctx.params)

domaintools/cli/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
# feeds
4343
FEEDS_NAD = "nad"
4444
FEEDS_NOD = "nod"
45+
FEEDS_NOH = "noh"
4546
FEEDS_DOMAINRDAP = "domainrdap"
4647
FEEDS_DOMAINDISCOVERY = "domaindiscovery"

domaintools/cli/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _iris_investigate_helptext():
6363
c.IRIS_DETECT_IGNORED_DOMAINS: "Returns back a list of ignored domains in Iris Detect based on the provided filters.",
6464
c.FEEDS_NAD: "Returns back newly active domains feed.",
6565
c.FEEDS_NOD: "Returns back newly observed domains feed.",
66+
c.FEEDS_NOH: "Returns back newly observed hosts feed.",
6667
c.FEEDS_DOMAINRDAP: "Returns changes to global domain registration information, populated by the Registration Data Access Protocol (RDAP).",
6768
c.FEEDS_DOMAINDISCOVERY: "Returns new domains as they are either discovered in domain registration information, observed by our global sensor network, or reported by trusted third parties.",
6869
}

domaintools/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class OutputFormat(Enum):
2828
"newly-active-domains-feed-(s3)",
2929
"newly-observed-domains-feed-(api)",
3030
"newly-observed-domains-feed-(s3)",
31+
"newly-observed-hosts-feed-(api)",
32+
"newly-observed-hosts-feed-(s3)",
3133
"domain-registration-data-access-protocol-feed-(api)",
3234
"domain-registration-data-access-protocol-feed-(s3)",
3335
"real-time-domain-discovery-feed-(api)",

requirements/common.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
httpx==0.22.0
1+
httpx

0 commit comments

Comments
 (0)