Skip to content

Commit 9c541e5

Browse files
author
Trevor
authored
Merge pull request #133 from InQuest/dev
v1.0.3
2 parents 85f9cc5 + 5caf299 commit 9c541e5

13 files changed

Lines changed: 127 additions & 28 deletions

File tree

config.example.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,38 @@ sources:
7575
url: https://inquest.net/blog/rss
7676
feed_type: messy
7777

78-
- name: inquest-blog
78+
# Sitemap exmaples
79+
80+
# Searches for "articles" keyword
81+
- name: inquest-sitemap-articles
82+
module: sitemap
83+
url: https://www.inquest.net/sitemap.xml
84+
filter: articles
85+
86+
# Defaults to "blog" keyword
87+
- name: inquest-sitemap-blog
88+
module: sitemap
89+
url: https://www.inquest.net/sitemap.xml
90+
91+
# Searches for "articles or security" keywords
92+
- name: inquest-sitemap-blog-articles-security
93+
module: sitemap
94+
url: https://www.inquest.net/sitemap.xml
95+
filter: articles|security
96+
97+
# Specify directories in the filter
98+
- name: inquest-sitemap-blog-category
99+
module: sitemap
100+
url: https://www.inquest.net/sitemap.xml
101+
path: /blog/category/
102+
103+
# Specify filtering for paths
104+
# Only returns results under /blog/category/release|solutions
105+
- name: inquest-sitemap-release-solutions
79106
module: sitemap
80-
url: https://inquest.net/sitemap.xml
107+
url: https://www.inquest.net/sitemap.xml
108+
path: /blog/category/
109+
filter: release|solutions
81110

82111
- name: image-extraction
83112
module: image

docs/_static/logo.png

13.6 KB
Loading

docs/_templates/links.html

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ <h3>Other Projects</h3>
3131
<ul>
3232
<li><a href="https://github.com/InQuest/ThreatKB">ThreatKB</a></li>
3333
<li><a href="https://github.com/InQuest/python-iocextract">iocextract</a></li>
34-
<li><a href="https://github.com/InQuest/omnibus">Omnibus</a></li>
3534
<li><a href="https://github.com/InQuest/python-sandboxapi">sandboxapi</a></li>
35+
<li><a href="https://github.com/InQuest/python-inquestlabs">inquestlabs
36+
</a></li>
3637
</ul>
3738

3839
<h3>Useful Links</h3>
@@ -46,24 +47,40 @@ <h3>Useful Links</h3>
4647
<h3>Stay Informed</h3>
4748

4849
<ul>
50+
<li>
51+
<a href="https://labs.inquest.net/">
52+
<img src="_static/logo.png" width="4%" alt="InQuest logo">
53+
InQuest Labs
54+
</a>
55+
</li>
56+
<li>
57+
<a href="https://inquest.net/newsletter">
58+
<img src="_static/logo.png" width="4%" alt="InQuest logo">
59+
InQuest Newsletter
60+
</a>
61+
</li>
4962
<li>
5063
<a href="http://blog.inquest.net/">
51-
<svg class="icon icon-rss"><use xlink:href="#icon-rss"></use></svg> InQuest Blog
64+
<svg class="icon icon-rss"><use xlink:href="#icon-rss"></use></svg>
65+
InQuest Blog
5266
</a>
5367
</li>
5468
<li>
5569
<a href="https://twitter.com/InQuest">
56-
<svg class="icon icon-twitter"><use xlink:href="#icon-twitter"></use></svg> Twitter
70+
<svg class="icon icon-twitter"><use xlink:href="#icon-twitter"></use></svg>
71+
Twitter
5772
</a>
5873
</li>
5974
<li>
6075
<a href="https://www.linkedin.com/company/inquest.net">
61-
<svg class="icon icon-linkedin"><use xlink:href="#icon-linkedin"></use></svg> LinkedIn
76+
<svg class="icon icon-linkedin"><use xlink:href="#icon-linkedin"></use></svg>
77+
LinkedIn
6278
</a>
6379
</li>
6480
<li>
6581
<a href="https://github.com/InQuest">
66-
<svg class="icon icon-github"><use xlink:href="#icon-github"></use></svg> GitHub
82+
<svg class="icon icon-github"><use xlink:href="#icon-github"></use></svg>
83+
GitHub
6784
</a>
6885
</li>
6986
</ul>

docs/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ github
168168
:member-order: bysource
169169

170170
github_gist
171-
^^^^^^
171+
^^^^^^^^^^^
172172

173173
.. automodule:: threatingestor.sources.github_gist
174174
:members:

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# -- Project information -----------------------------------------------------
2121

2222
project = u'ThreatIngestor'
23-
copyright = u'2019 InQuest, LLC'
23+
copyright = u'2019 - 2023 InQuest, LLC'
2424
author = u'InQuest Labs'
2525

2626
# The short X.Y version

docs/sources/github_gist.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.. _github-gist-source:
22

33
GitHub Gist Username Search
4-
------------------------
4+
---------------------------
55

6-
The **GitHub Gist** source plugin uses GitHub's `gist API`_ to find new gists created by a user, and create a :ref:`Task artifact <task-artifact>` for each.
6+
The **GitHub Gist** source plugin uses GitHub's gist API to find new gists created by a user, and create a :ref:`Task artifact <task-artifact>` for each.
77

88
Configuration Options
99
~~~~~~~~~~~~~~~~~~~~~

requirements-testing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ twitter>=1.17.1
1515
feedparser>=5.2.1
1616
threatkb
1717
pymysql
18+
pyshorteners

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ requests
1010
pytesseract
1111
numpy
1212
opencv-python
13+
pyshorteners

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name='threatingestor',
23-
version='1.0.2',
23+
version='1.0.3',
2424
include_package_data=True,
2525
install_requires=requires,
2626
extras_require={

threatingestor/sources/sitemap.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
import urllib.request
33
from urllib.parse import urlparse
44
from bs4 import BeautifulSoup
5+
import regex as re
56

67
from threatingestor.sources import Source
78

89
class Plugin(Source):
910

10-
def __init__(self, name, url):
11+
def __init__(self, name, url, filter=None, path=None):
1112
self.name = name
1213
self.url = url
14+
self.filter = filter
15+
self.path = path
1316

1417
def run(self, saved_state):
1518
saved_state = datetime.datetime.utcnow().isoformat()[:-7] + "Z"
@@ -58,9 +61,35 @@ def run(self, saved_state):
5861
"loc": loc
5962
}
6063

61-
# Locates all blog links within the sitemap
62-
if "blog" in row["loc"]:
63-
print(row["loc"])
64-
artifacts += self.process_element(row["loc"], self.url)
64+
if self.filter is not None:
65+
# Regex input via config.yml
66+
xml_query = re.compile(r"{0}".format(self.filter)).findall(str(self.filter.split('|')))
67+
68+
# Iterates over the regex output to locate all provided keywords
69+
for x in xml_query:
70+
# Uses a path instead of a keyword
71+
if self.path is not None:
72+
provided_path = f"{self.path}{x}"
73+
74+
if provided_path in row["loc"]:
75+
artifacts += self.process_element(row["loc"], self.url)
76+
77+
# Only filters using a keyword
78+
if self.path is None:
79+
if x in row["loc"]:
80+
artifacts += self.process_element(row["loc"], self.url)
81+
82+
elif self.filter is None and self.path is not None:
83+
# Filters only by path in XML loc, no set filter
84+
# Default: /path/name/*
85+
provided_path = f"{self.path}"
86+
87+
if provided_path in row["loc"]:
88+
artifacts += self.process_element(row["loc"], self.url)
89+
90+
else:
91+
# Locates all blog links within the sitemap
92+
if "blog" in row["loc"]:
93+
artifacts += self.process_element(row["loc"], self.url)
6594

6695
return saved_state, artifacts

0 commit comments

Comments
 (0)