Skip to content

Commit d82f351

Browse files
authored
Merge pull request #102 from intelowlproject/develop
version 1.0.0
2 parents a12ca72 + 2097225 commit d82f351

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+5492
-2962
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
.gitignore
2+
.vscode
23
__pycache__
4+
.env
35
env_file_app
4-
env_file_postgres
6+
env_file_postgres
7+
env_file_integrations
8+
venv/

.env_template

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
### the COMPOSE_FILE variable each seperated with ':'. If you are on windows, replace all ':' with ';'.
66
### Reference to Docker's official Docs: https://docs.docker.com/compose/reference/envvars/#compose_file#compose_file
77

8-
## Default
8+
###### Default (Production) ######
9+
910
COMPOSE_FILE=docker-compose.yml
1011

11-
## To run all additional integrations
12+
## To run all additional integrations in production
1213
#COMPOSE_FILE=docker-compose.yml:./integrations/docker-compose.peframe.yml
1314

14-
## To run tests or for local development
15+
###### For Tests or local development ######
16+
1517
#COMPOSE_FILE=docker-compose-for-tests.yml
18+
19+
## To run all additional integrations in development
1620
#COMPOSE_FILE=docker-compose-for-tests.yml:./integrations/docker-compose-for-tests.peframe.yml
1721

18-
## For travis
19-
#COMPOSE_FILE=docker-compose-for-travis.yml
22+
###### For travis ######
23+
2024
#COMPOSE_FILE=docker-compose-for-travis.yml./integrations/docker-compose.peframe.yml

.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
max-line-length = 88
3+
ignore =
4+
W503, # line break before binary operator
5+
E231, # missing whitespace after ','
6+
exclude =
7+
Dockerfile,
8+
docker-compose*,
9+
venv,
10+
migrations,
11+
virtualenv

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ install:
1616
- sudo docker-compose -f docker-compose-for-travis.yml build
1717
- sudo docker-compose -f docker-compose-for-travis.yml up -d
1818
script:
19-
- sudo docker exec -ti intel_owl_uwsgi python manage.py test tests
20-
19+
- sudo docker exec -ti intel_owl_uwsgi black . --check --exclude "migrations|venv"
20+
- sudo docker exec -ti intel_owl_uwsgi flake8 . --count
21+
- sudo docker exec -ti intel_owl_uwsgi python manage.py test tests

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ ENV PYTHONPATH /opt/deploy/intel_owl
66

77
RUN mkdir -p /var/log/intel_owl /var/log/intel_owl/django /var/log/intel_owl/uwsgi /opt/deploy/files_required /opt/deploy/yara /opt/deploy/configuration
88

9-
RUN apt-get update
10-
RUN apt-get install -y --no-install-recommends apt-utils libsasl2-dev libssl-dev vim libfuzzy-dev net-tools python-psycopg2 git osslsigncode exiftool
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends apt-utils libsasl2-dev libssl-dev \
11+
vim libfuzzy-dev net-tools python-psycopg2 git osslsigncode exiftool \
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
1114
RUN pip3 install --upgrade pip
1215

1316
COPY requirements.txt $PYTHONPATH/requirements.txt

Dockerfile_nginx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
# Stage 1: Get build artifacts from intelowl-ng
2+
FROM intelowlproject/intelowl_ng:latest AS angular-prod-build
3+
4+
# Stage 2: Inject the build artifacts into nginx container
15
FROM library/nginx:1.16.1-alpine
6+
7+
COPY --from=angular-prod-build /usr/src/app/dist /var/www/angular_build
28
VOLUME /var/log/nginx

Dockerfile_nginx_no_angular

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM library/nginx:1.16.1-alpine
2+
VOLUME /var/log/nginx

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/intelowlproject/IntelOwl.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/intelowlproject/IntelOwl/context:python)
55
[![CodeFactor](https://www.codefactor.io/repository/github/intelowlproject/intelowl/badge)](https://www.codefactor.io/repository/github/intelowlproject/intelowl)
66
[![Build Status](https://travis-ci.com/intelowlproject/IntelOwl.svg?branch=master)](https://travis-ci.org/intelowlproject/IntelOwl)
7+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
8+
79
# Intel Owl
810

911
Do you want to get **threat intelligence data** about a file, an IP or a domain?
@@ -24,6 +26,7 @@ Main features:
2426
- full django-python application
2527
- easily and completely customizable, both the APIs and the analyzers
2628
- clone the project, set up the configuration and you are ready to run
29+
- Official frontend client: **[IntelOwl-ng](https://github.com/intelowlproject/IntelOwl-ng)** provides features such as dashboard, visualizations of analysis data, easy to use forms for requesting new analysis, etc.
2730

2831
### Free internal modules available
2932
* Static Doc Analysis
@@ -37,7 +40,7 @@ Main features:
3740
### Free modules that require additional configuration
3841
* Cuckoo (requires at least one working Cuckoo instance)
3942
* MISP (requires at least one working MISP instance)
40-
* Yara (Community, Neo23x0 and Intezer rules are already available. There's the chance to add your own rules)
43+
* Yara (Community, Neo23x0, Intezer and McAfee rules are already available. There's the chance to add your own rules)
4144

4245
### External services available
4346
#### required paid or trial api key
@@ -70,8 +73,11 @@ Main features:
7073
* Threatminer
7174
* Abuse.ch MalwareBazaar
7275
* Abuse.ch URLhaus
76+
* Team Cymru Malware Hash Registry
77+
* Tranco Rank
7378
* Google DoH
74-
* CloudFlare DoH
79+
* CloudFlare DoH Classic
80+
* CloudFlare DoH Malware
7581
* Classic DNS resolution
7682

7783
### Documentation
@@ -99,7 +105,8 @@ license terms.
99105
[GitPython](https://github.com/gitpython-developers/GitPython),
100106
[Yara community rules](https://github.com/Yara-Rules),
101107
[Neo23x0 Yara sigs](https://github.com/Neo23x0/signature-base),
102-
[Intezer Yara sigs](https://github.com/intezer/yara-rules)
108+
[Intezer Yara sigs](https://github.com/intezer/yara-rules),
109+
[McAfee Yara sigs](https://github.com/advanced-threat-research/Yara-Rules)
103110

104111
### Acknowledgments
105112
This project was created and will be upgraded thanks to the following organizations:
@@ -111,9 +118,9 @@ This project was created and will be upgraded thanks to the following organizati
111118
#### Google Summer Of Code
112119
The project was accepted to the GSoC 2020 under the Honeynet Project!!
113120

114-
Stay tuned for upcoming [new features](https://www.honeynet.org/gsoc/gsoc-2020/google-summer-of-code-2020-project-ideas/#intel-owl-improvements) developed by Eshann Bansal [Twitter](https://twitter.com/mask0fmydisguis)
121+
Stay tuned for upcoming [new features](https://www.honeynet.org/gsoc/gsoc-2020/google-summer-of-code-2020-project-ideas/#intel-owl-improvements) developed by Eshaan Bansal ([Twitter](https://twitter.com/mask0fmydisguis)).
115122

116123

117124
### About the author
118125
Feel free to contact the author at any time:
119-
Matteo Lodi [Twitter](https://twitter.com/matte_lodi)
126+
Matteo Lodi ([Twitter](https://twitter.com/matte_lodi))

api_app/admin.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
from django.contrib import admin
2+
3+
from rest_framework_simplejwt.token_blacklist.admin import OutstandingTokenAdmin
4+
from rest_framework_simplejwt.token_blacklist.models import OutstandingToken
5+
from rest_framework_simplejwt.tokens import RefreshToken
6+
from rest_framework_simplejwt.utils import datetime_from_epoch
7+
28
from .models import Job, Tag
9+
from intel_owl.settings import CLIENT_TOKEN_LIFETIME_DAYS, SIMPLE_JWT as jwt_settings
310

411

512
class JobAdminView(admin.ModelAdmin):
@@ -21,5 +28,89 @@ class TagAdminView(admin.ModelAdmin):
2128
search_fields = ("label", "color")
2229

2330

31+
# SimpleJWT stuff
32+
class CustomOutstandingTokenAdmin(OutstandingTokenAdmin):
33+
"""
34+
Custom admin view for OutstandingToken model of simplejwt package\n
35+
allows bulk deletion and refresh token creation
36+
"""
37+
38+
# default actions
39+
actions = []
40+
41+
# searchable fields
42+
search_fields = (
43+
"user__username",
44+
"user__id",
45+
"jti",
46+
)
47+
48+
__fieldsets_custom = [
49+
(
50+
"Create API Token For",
51+
{
52+
"fields": ("user", "token",),
53+
"description": f"""
54+
<h3>Token will be auto-generated on save.</h3>
55+
<h5>Please note that this token,</h5>
56+
<ol>
57+
<li>can only be used with the PyIntelOwl client.</li>
58+
<li>is rotated on every authenticated request
59+
and saves itself via pyintelowl</li>
60+
<li>
61+
automatically expires if goes
62+
unused for {CLIENT_TOKEN_LIFETIME_DAYS} days.
63+
</li>
64+
</ol>
65+
""",
66+
},
67+
),
68+
]
69+
70+
def add_view(self, request, extra_content=None):
71+
self.fieldsets = self.__fieldsets_custom
72+
return super(CustomOutstandingTokenAdmin, self).add_view(request)
73+
74+
def get_readonly_fields(self, *args, **kwargs):
75+
fields = [f.name for f in self.model._meta.fields]
76+
# only user field is writeable
77+
fields.remove("user")
78+
return fields
79+
80+
def has_delete_permission(self, *args, **kwargs):
81+
return True
82+
83+
def has_add_permission(self, *args, **kwargs):
84+
return True
85+
86+
def has_change_permission(self, *args, **kwargs):
87+
return False
88+
89+
def save_model(self, request, obj, form, change):
90+
if obj.user:
91+
refresh = RefreshToken()
92+
# custom claims
93+
refresh["client"] = "pyintelowl"
94+
refresh["user_id"] = obj.user.id
95+
# overwrite lifetime/expiry
96+
refresh.set_exp(
97+
lifetime=jwt_settings.get("PYINTELOWL_TOKEN_LIFETIME", None)
98+
)
99+
token = OutstandingToken.objects.create(
100+
user=obj.user,
101+
jti=refresh.payload["jti"],
102+
token=str(refresh),
103+
created_at=refresh.current_time,
104+
expires_at=datetime_from_epoch(refresh["exp"]),
105+
)
106+
return token
107+
108+
return None
109+
110+
24111
admin.site.register(Job, JobAdminView)
25112
admin.site.register(Tag, TagAdminView)
113+
# Unregister the default admin view for OutstandingToken
114+
admin.site.unregister(OutstandingToken)
115+
# Register our custom admin view for OutstandingToken
116+
admin.site.register(OutstandingToken, CustomOutstandingTokenAdmin)

0 commit comments

Comments
 (0)