Skip to content
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

Release: SSO, JSON field types, and File Upload Mutations #513

Merged
merged 99 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
89f16ca
Add uploadEvidence graphql mutation
ColonelThirtyTwo Jun 11, 2024
3bb1a77
Add uploadReportTemplate graphql mutation
ColonelThirtyTwo Jun 24, 2024
bdc3961
Add JSON extra field type
ColonelThirtyTwo Jun 18, 2024
fd4937a
Defer loading of extra_fields on project lists
ColonelThirtyTwo Jun 21, 2024
01a22dd
Merge branch 'master' into extra-field-json
ColonelThirtyTwo Jul 24, 2024
8321615
Merge branch 'master' into graphql-api-file-upload-dev
ColonelThirtyTwo Jul 24, 2024
ed7969a
Merge branch 'master' into graphql-api-file-upload-dev
chrismaddalena Jul 29, 2024
bfd9478
Fix linting issues, add test for evidence upload
ColonelThirtyTwo Jul 30, 2024
9fbb218
Merge branch 'graphql-api-file-upload-dev' into json-and-file-upload-dev
ColonelThirtyTwo Aug 5, 2024
23bfa84
Merge branch 'extra-field-json' into json-and-file-upload-dev
ColonelThirtyTwo Aug 5, 2024
c95104c
Removed duplicate JSOn field display
chrismaddalena Aug 7, 2024
b1afa60
Added check for decode errors for evidence display
chrismaddalena Aug 7, 2024
3fcab66
Changes to profiles and emails for SSO additions
chrismaddalena Aug 13, 2024
6ba3e0d
Fixed template issue with blocks
chrismaddalena Aug 13, 2024
b3e3b67
Initial commit of customized social adapter
chrismaddalena Aug 13, 2024
d822464
Added social account domain allowlist
chrismaddalena Aug 14, 2024
64e4a62
Adjusted reg unavailable page to be more helpful for troubleshooting
chrismaddalena Aug 14, 2024
c565a9a
Added social reg domain allowlist option
chrismaddalena Aug 14, 2024
0e5e793
Initial commit for user-created settings files
chrismaddalena Aug 14, 2024
4b914ea
Applied changes from PR #501
chrismaddalena Aug 14, 2024
f27b935
Updated to implement the social domain allowlist
chrismaddalena Aug 14, 2024
150c7e6
Updated adapter with logging and better allowlist handling
chrismaddalena Aug 15, 2024
cc4f789
Fixed instructions in comments
chrismaddalena Aug 15, 2024
cd1e823
Added config for `SOCIALACCOUNT_LOGIN_ON_GET` for easier control
chrismaddalena Aug 15, 2024
f375e51
Updated binaries to v0.2.20
chrismaddalena Aug 15, 2024
09a5111
Updated for `django-allauth` v0.63.6
chrismaddalena Aug 16, 2024
11aee93
Bumped `django-allauth` to v0.63.6
chrismaddalena Aug 16, 2024
f54e218
Customized sign-up page to make it look better
chrismaddalena Aug 16, 2024
060d4f5
Added customized `UserSignupForm`
chrismaddalena Aug 16, 2024
0562f71
Linting change
chrismaddalena Aug 16, 2024
0de6dd0
Changed `EMAIL_BACKEND` default to console from Mailgun example
chrismaddalena Aug 16, 2024
1a88833
Updated use config options available in `django-allauth` v0.63.6
chrismaddalena Aug 16, 2024
19ec9c2
Merge branch 'master' into feature/sso-adapter
chrismaddalena Aug 28, 2024
2d22816
Merge branch 'feature/sso-adapter' into feature/sso-json-and-file-api
chrismaddalena Aug 28, 2024
12f0725
Merge branch `json-and-file-upload-dev`
chrismaddalena Aug 28, 2024
64a1ff3
Centered modals for easier reading and consistency
chrismaddalena Aug 28, 2024
4e1bc31
Made modals scrollable for lengthy content
chrismaddalena Aug 28, 2024
3100bd5
Changed JSON preview button text
chrismaddalena Aug 29, 2024
096bfa1
Changed `pre` to have a width of 90vw
chrismaddalena Aug 29, 2024
d1febf9
Initial commit of modified jsonview JS and CSS
chrismaddalena Aug 29, 2024
f19fa40
Add imports for jsonview
chrismaddalena Aug 29, 2024
f3ae005
Removed centered modal class
chrismaddalena Aug 29, 2024
2f6596b
Changed JSON previews to use jsonview
chrismaddalena Aug 29, 2024
342abb0
Changed file display error to display as an alert
chrismaddalena Aug 29, 2024
dc7b314
Added setting `uploaded_by` to forms
chrismaddalena Aug 29, 2024
a0df6ea
Applied patch from #508
chrismaddalena Aug 29, 2024
360b7d6
Check file extension for evidence created from GraphQL
ColonelThirtyTwo Aug 29, 2024
9200b8b
Check for invalid text on report generation
ColonelThirtyTwo Aug 29, 2024
29f632e
Also allow uppercase extensions in GQL evidence upload
ColonelThirtyTwo Aug 29, 2024
b9d47ae
Fix GQL evidence upload not working
ColonelThirtyTwo Aug 29, 2024
3b8f549
Clean error when trying to use invalid image
ColonelThirtyTwo Aug 30, 2024
3f9805c
Added aux IP addresses to cloud infra checks
chrismaddalena Sep 3, 2024
91b0f3f
Changed img evidence to a max-width to keep previews smaller
chrismaddalena Sep 3, 2024
e0c1c80
Linting clean-up
chrismaddalena Sep 3, 2024
45ee83f
Adjusted sign-up form
chrismaddalena Sep 3, 2024
81c08ca
Added test for `UserSignUpForm`
chrismaddalena Sep 3, 2024
dded444
Added error code
chrismaddalena Sep 4, 2024
56048ca
Added `ApiEvidenceFormTests`
chrismaddalena Sep 4, 2024
fc0e130
Added some validation for report template filetypes
chrismaddalena Sep 5, 2024
75083a8
Added validation for report template and client filtering files
chrismaddalena Sep 5, 2024
0549f17
Added tests for `ApiReportTemplateForm`
chrismaddalena Sep 5, 2024
19bd566
Clean up and explicit error checks
chrismaddalena Sep 5, 2024
cde8706
Added explicit tests for invalid document content
chrismaddalena Sep 5, 2024
0d52b06
Updated for the v4.3.0 release
chrismaddalena Sep 5, 2024
71af5f5
Fix error when trying to create a new object with extra fields
ColonelThirtyTwo Sep 10, 2024
46111b4
Fix error when having a blockquote in a list
ColonelThirtyTwo Sep 10, 2024
3646614
Changed call `dict()` to `{}`
chrismaddalena Sep 10, 2024
ba65700
Removed unique constraint from the `ip_address` field
chrismaddalena Sep 10, 2024
8e89c57
Added warnings if multiple project servers share an IP address
chrismaddalena Sep 10, 2024
ded6d59
Removed unused img files
chrismaddalena Sep 10, 2024
07851d4
Cleaned up unused image files
chrismaddalena Sep 10, 2024
6371b88
Added updated logo image files and inverted versions
chrismaddalena Sep 10, 2024
204b3d3
Added labels to ignore
chrismaddalena Sep 10, 2024
e6d36a9
Updated for delayed release
chrismaddalena Sep 10, 2024
ab77bf4
Added shared func for filtering tags with `django-filters`
chrismaddalena Sep 10, 2024
1ee1de6
Updated filters to use the shared `search_tags` func
chrismaddalena Sep 10, 2024
6e51835
Added a "Tags" column to the tables
chrismaddalena Sep 10, 2024
1e4a0d6
Updated for the latest changes
chrismaddalena Sep 10, 2024
52d8b5c
Merge branch 'master' into feature/sso-json-and-file-api
chrismaddalena Sep 10, 2024
fcbaf6f
Merge branch 'master' into feature/sso-json-and-file-api
chrismaddalena Sep 17, 2024
99b32ce
Removed repeated forgot password link
chrismaddalena Sep 18, 2024
7347005
Merge branch 'feature/sso-json-and-file-api' of https://github.com/Gh…
chrismaddalena Sep 18, 2024
426e527
Merged duplicate 0050 migration files
chrismaddalena Sep 18, 2024
915587f
Removed broke `p` element
chrismaddalena Sep 18, 2024
eb9975d
Fixed user profile always showing current user's profile picture
chrismaddalena Sep 19, 2024
7cba799
Removed duplicated `update_badges()`
chrismaddalena Sep 19, 2024
f250bc5
Changed autocomplete to attach clicked items
chrismaddalena Sep 19, 2024
199cdfe
Moved findings and observations tables and related JS to dedicated files
chrismaddalena Sep 19, 2024
f4bc445
Updated styling for autocomplete boxes
chrismaddalena Sep 19, 2024
2512d58
Added autocomplete for observations and return table HTML on assignment
chrismaddalena Sep 19, 2024
6a0bd4f
Automated code format clean up
chrismaddalena Sep 20, 2024
d6bd2ed
Updated release date for final v4.3.0
chrismaddalena Sep 20, 2024
c73f2d8
Fixed assignee color not syncing with finding status changes
chrismaddalena Sep 20, 2024
fc685c4
Updated views to also use an optional `report` value from POST
chrismaddalena Sep 20, 2024
2127ae2
Changed "Add Blank" buttons to not require a page refresh
chrismaddalena Sep 20, 2024
438c5f2
Updated tests to match view changes
chrismaddalena Sep 23, 2024
ad0b177
Fixed tests for new JSON response
chrismaddalena Sep 23, 2024
667988b
Added a check to see if cloud server shares an IP with a checkout
chrismaddalena Sep 23, 2024
f3fe783
Updated wiki links for release
chrismaddalena Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/inactive-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ jobs:
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
exempt-issue-labels: "enhancement, help wanted, question, in progress"
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# CHANGELOG

## [4.3.0] – 23 Sep 2024

### Added

* Added two mutations to the GraphQL API to support uploading new evidence files and report template files (Closes #230)
* Added a new adapter for handling authentication for Single Sign-On (SSO) providers
* The adapter fills-in a nearly full profile for any new accounts (full name, email address, username)
* Usernames for new accounts will default to the first half of the email address
* If an existing account has the same email address, the accounts will be linked
* Review the wiki for more information: [https://www.ghostwriter.wiki/features/access-authentication-and-session-controls/single-sign-on](https://www.ghostwriter.wiki/features/access-authentication-and-session-controls/single-sign-on)
* Added support for loading customized config files
* These are files you can use to modify settings normally found in _/config/settings/base.py_ and _production.py_
* Admins can make changes to the custom config files without worrying about the changes needing to be stashed prior to pulling an update
* Review this section of the wiki for information: [https://www.ghostwriter.wiki/features/access-authentication-and-session-controls/single-sign-on#configuring-an-sso-provider](https://www.ghostwriter.wiki/features/access-authentication-and-session-controls/single-sign-on#configuring-an-sso-provider)
* Added support for a JSON field type for custom fields
* Added a "Tags" column to the domain and server library tables

### Changed

* Updated the `django-allauth` module used for authentication and SSO
* **Important:** This change impacts anyone currently using SSO with Azure
* The `azure` provider is now `microsoft` and SSO configurations will need to be updated
* Changed the cloud infrastructure monitoring task to also check auxiliary IP addresses when determining if a cloud host is tracked in a project
* Cloud hosts tracked on a project no longer require a unique IP address
* A warning is displayed if a cloud host is tracked on a project with multiple hosts sharing the same IP address
* Changed filtering on tags to be case-insensitive
* On the report dashboard, clicking an autocomplete suggestion for a finding or observation will now add the item to the report

### Fixed

* Fixed spaces disappearing after Microsoft Word cross-references placed at the beginning of a new line or paragraph

### [4.2.5] - 7 August 2024

### Changed
Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
v4.2.5
9 August 2024
v4.3.0
23 September 2024
47 changes: 45 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# 3rd Party Libraries
import environ

__version__ = "4.2.5"
__version__ = "4.3.0"
VERSION = __version__
RELEASE_DATE = "9 August 2024"
RELEASE_DATE = "23 September 2024"

ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
APPS_DIR = ROOT_DIR / "ghostwriter"
Expand Down Expand Up @@ -195,6 +195,7 @@
"django_otp.middleware.OTPMiddleware",
"allauth_2fa.middleware.AllauthTwoFactorMiddleware",
"ghostwriter.middleware.Require2FAMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

# STATIC
Expand Down Expand Up @@ -321,6 +322,8 @@
# ------------------------------------------------------------------------------
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", False)
SOCIAL_ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_SOCIAL_ACCOUNT_ALLOW_REGISTRATION", False)
SOCIAL_ACCOUNT_DOMAIN_ALLOWLIST = env("DJANGO_SOCIAL_ACCOUNT_DOMAIN_ALLOWLIST", default="")
SOCIALACCOUNT_LOGIN_ON_GET = env.bool("DJANGO_SOCIAL_ACCOUNT_LOGIN_ON_GET", False)
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_AUTHENTICATION_METHOD = "username"
# https://django-allauth.readthedocs.io/en/latest/configuration.html
Expand All @@ -334,6 +337,7 @@
ACCOUNT_SIGNUP_FORM_CLASS = "ghostwriter.home.forms.SignupForm"
ACCOUNT_FORMS = {
"login": "ghostwriter.users.forms.UserLoginForm",
"signup": "ghostwriter.users.forms.UserSignupForm",
}
ALLAUTH_2FA_FORMS = {
"authenticate": "ghostwriter.users.forms.User2FAAuthenticateForm",
Expand Down Expand Up @@ -497,3 +501,42 @@
# Tagging
# ------------------------------------------------------------------------------
TAGGIT_CASE_INSENSITIVE = True


def include_settings(py_glob):
"""
Includes a glob of Python settings files.
The files will be sorted alphabetically.
"""
import sys
import os
import glob
from importlib.util import module_from_spec, spec_from_file_location

# Get caller's global scope
scope = sys._getframe(1).f_globals

including_path = scope["__file__"].rstrip("c")
including_dir = os.path.dirname(including_path)
py_glob_rel = os.path.join(including_dir, py_glob)

for relpath in sorted(glob.glob(py_glob_rel)):
# Read and execute files
with open(relpath, "rb") as f:
contents = f.read()
compiled = compile(contents, relpath, "exec")
# Use of `exec` is typically dangerous, but we're only executing our own settings files
# The settings files are user controlled, but any danger represented by executing them also applies to executing the main settings files
# The primary concern is an admin could unwittingly execute a malicious settings file they did not realize was present
# However, an admin could also unwittingly run a malicious command in the main settings file
exec(compiled, scope)

# Adds dummy module to sys.modules so runserver will reload if they change
rel_path = os.path.relpath(including_path)
module_name = "_settings_include.{0}".format(
rel_path[: rel_path.rfind(".")].replace("/", "."),
)

spec = spec_from_file_location(module_name, including_path)
module = module_from_spec(spec)
sys.modules[module_name] = module
2 changes: 2 additions & 0 deletions config/settings/local.d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!/.gitignore
14 changes: 7 additions & 7 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
default="Vso7i8BApwA6km4L50PFRvqcTtGZHLrC1pnKLCXqfTWifhjbGq4nTd6ZrDH2Iobe",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
hosts = env(
"DJANGO_ALLOWED_HOSTS",
default="localhost 0.0.0.0 127.0.0.1 172.20.0.5 django host.docker.internal"
)
hosts = env("DJANGO_ALLOWED_HOSTS", default="localhost 0.0.0.0 127.0.0.1 172.20.0.5 django host.docker.internal")
ALLOWED_HOSTS = hosts.split(" ")

# CACHES
Expand All @@ -30,9 +27,7 @@
# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
)
EMAIL_BACKEND = env("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend")
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = "localhost"
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
Expand Down Expand Up @@ -70,3 +65,8 @@
# LOGGING.setdefault("loggers", {})["django.db.backends"] = {
# "level": "DEBUG"
# }

# Include files in `local.d`. These are added in alphabetical order - using a numeric prefix
# like `10-subconfig.py` can be used to order inclusions

include_settings("./local.d/*.py")
2 changes: 2 additions & 0 deletions config/settings/production.d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!/.gitignore
27 changes: 10 additions & 17 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env("DJANGO_SECRET_KEY")
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
hosts = env(
"DJANGO_ALLOWED_HOSTS",
default="ghostwriter.local localhost host.docker.internal"
)
hosts = env("DJANGO_ALLOWED_HOSTS", default="ghostwriter.local localhost host.docker.internal")
ALLOWED_HOSTS = hosts.split(" ")

# DATABASES
Expand Down Expand Up @@ -48,9 +45,7 @@
# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
SECURE_HSTS_SECONDS = 60
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
"DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True
)
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool("DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True)
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
Expand All @@ -75,9 +70,7 @@
# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
DEFAULT_FROM_EMAIL = env(
"DJANGO_DEFAULT_FROM_EMAIL", default="Ghostwriter <[email protected]>"
)
DEFAULT_FROM_EMAIL = env("DJANGO_DEFAULT_FROM_EMAIL", default="Ghostwriter <[email protected]>")
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
Expand All @@ -92,7 +85,7 @@
# ------------------------------------------------------------------------------
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
INSTALLED_APPS += ["anymail"] # noqa F405
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
ANYMAIL = {
"MAILGUN_API_KEY": env("MAILGUN_API_KEY"),
Expand Down Expand Up @@ -127,12 +120,7 @@
"version": 1,
"disable_existing_loggers": False,
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
"formatters": {
"verbose": {
"format": "%(levelname)s %(asctime)s %(module)s "
"%(process)d %(thread)d %(message)s"
}
},
"formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s"}},
"handlers": {
"mail_admins": {
"level": "ERROR",
Expand Down Expand Up @@ -162,3 +150,8 @@

# Your stuff...
# ------------------------------------------------------------------------------

# Include files in `production.d`. These are added in alphabetical order - using a numeric prefix
# like `10-subconfig.py` can be used to order inclusions

include_settings("./production.d/*.py")
Binary file modified ghostwriter-cli-linux
Binary file not shown.
Binary file modified ghostwriter-cli-macos
Binary file not shown.
Binary file modified ghostwriter-cli.exe
Binary file not shown.
Loading