-
Notifications
You must be signed in to change notification settings - Fork 2
Fix django bugs #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix django bugs #16
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
91f44fc
Make sure manage.py calls "django" specifically
025b338
Update django-gunicorn app to use form data instead of url
63d5210
Add healthcheck to django-mysql-gunicorn application
2725e1a
Fix bugs with create_dog.html page
e1b1d89
Use os.fork, this fixes issues with django
0eefb54
It's a process not a thread, change this for clarity
650e3dd
Remove pymysql from sample-django apps and use mysqlcient instead (th…
edfca35
allow running without server and allow running server-only
be03cf0
Remove aikido imports from manage.py file
2932a80
Add gunicorn config file
7bd21da
Linting
4be81d2
Add django-gunicorn parsing
40211b6
django-gunicorn add to supported sources
45b2fea
Read body and rewrite it
b6b8c39
set_as_current_context
e560f2c
Cleanup config and make special "django-gunicorn" class
4d54f81
Merge branch 'main' into AIK-3199
bitterpanda63 1fd4c35
Merge remote-tracking branch 'origin/AIK-3167' into AIK-3199
00c3dd3
Linting after merge
f950962
Update test suite to use new reset_comms function
73c5fa4
Create reset_comms function and at timeout to sending data over IPC
8c3c04e
Add comments, "KILL" action and check if port is already in use
20e0ab6
Move send code to a thread
73c9205
Fix bugs with django-mysql sample app
d5d2384
Fix dogpage as well
60f7790
Merge branch 'main' into AIK-3199
willem-delbare 48e05f2
Update aikido_firewall/background_process/__init__.py
willem-delbare 80151a7
Renaming and splitting up files
4480e2b
Ignore global pylint error and explain threading (coomentz)
3dbf878
Split up testing, remove unused imports
9968b2e
Linting and import comms
c586dbb
Linting comment
673c889
Move gunicorn code to a file so our gunicorn config file is smaller
7f8f8aa
Merge branch 'AIK-3199' into move-ipc-to-seperate-file
bitterpanda63 7be09d2
Merge pull request #27 from AikidoSec/move-ipc-to-seperate-file
bitterpanda63 b212ef0
Rename "server-only" to "background-process-only"
2e2f63d
Update aikido_firewall/background_process/aikido_background_process.py
willem-delbare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import aikido_firewall | ||
import json | ||
from urllib.parse import parse_qs | ||
from io import BytesIO | ||
from aikido_firewall.context import Context | ||
from gunicorn.http.body import Body | ||
|
||
def when_ready(server): | ||
aikido_firewall.protect("server-only") | ||
|
||
def pre_fork(server, worker): | ||
pass | ||
|
||
def post_fork(server, worker): | ||
print("----------------------> POST FORK") | ||
import aikido_firewall | ||
aikido_firewall.protect("django-gunicorn", False) | ||
|
||
def pre_request(worker, req): | ||
req.body, req.body_copy = clone_body(req.body) | ||
|
||
django_context = Context(req, "django-gunicorn") | ||
django_context.set_as_current_context() | ||
|
||
worker.log.debug("%s %s", req.method, req.path) | ||
|
||
|
||
def clone_body(body): | ||
body_read = body.read() | ||
|
||
# Read the body content into a buffer | ||
body_buffer = BytesIO() | ||
body_buffer.write(body_read) | ||
body_buffer.seek(0) | ||
|
||
# Create a new Body object with the same content | ||
cloned_body = Body(body_buffer) | ||
|
||
return (cloned_body, body_read) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
django | ||
pymysql | ||
mysqlclient | ||
python-decouple | ||
cryptography | ||
gunicorn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
import pymysql | ||
pymysql.install_as_MySQLdb() | ||
7 changes: 7 additions & 0 deletions
7
sample-apps/django-mysql-gunicorn/sample_app/templates/app/create_dog.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1>Create a New Dog</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<label for="dog_name">Dog Name:</label> | ||
<input type="text" id="dog_name" name="dog_name"> | ||
<button type="submit">Create Dog</button> | ||
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename