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

Adds parameter for security classification #451

Merged
merged 7 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .env.django
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ FILE_EXPIRY_IN_DAYS=30
# === Playwright Tests ===

USER_EMAIL=

# === Security classifications ===
# The maximum security classification permitted for the app to handle

# OFFICIAL, OFFICIAL_SENSITIVE, SECRET or TOP_SECRET
MAX_SECURITY_CLASSIFICATION=OFFICIAL_SENSITIVE
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ FILE_EXPIRY_IN_DAYS=30
# === Playwright Tests ===

USER_EMAIL=

# === Security classifications ===
# The maximum security classification permitted for the app to handle

# OFFICIAL, OFFICIAL_SENSITIVE, SECRET or TOP_SECRET
MAX_SECURITY_CLASSIFICATION=OFFICIAL_SENSITIVE
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ FILE_EXPIRY_IN_DAYS=30
# === Playwright Tests ===

USER_EMAIL=

# === Security classifications ===
# The maximum security classification permitted for the app to handle

# OFFICIAL, OFFICIAL_SENSITIVE, SECRET or TOP_SECRET
MAX_SECURITY_CLASSIFICATION=OFFICIAL_SENSITIVE
2 changes: 2 additions & 0 deletions django_app/redbox_app/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def environment(**options):
"url": url,
"humanize_timedelta": humanize_timedelta,
"environment": settings.ENVIRONMENT,
"security": settings.MAX_SECURITY_CLASSIFICATION.value,
}
)
env.globals.update(
Expand All @@ -71,6 +72,7 @@ def environment(**options):
"url": url,
"humanize_timedelta": humanize_timedelta,
"environment": settings.ENVIRONMENT,
"security": settings.MAX_SECURITY_CLASSIFICATION.value,
}
)
return env
14 changes: 14 additions & 0 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors

import socket
from enum import StrEnum
from pathlib import Path

import environ
Expand Down Expand Up @@ -323,3 +324,16 @@
USE_STREAMING = env.bool("USE_STREAMING")
FILE_EXPIRY_IN_SECONDS = env.int("FILE_EXPIRY_IN_DAYS") * 24 * 60 * 60
SUPERUSER_EMAIL = env.str("SUPERUSER_EMAIL", None)

# Security classifications
# https://www.gov.uk/government/publications/government-security-classifications/


class Classification(StrEnum):
OFFICIAL = "Official"
OFFICIAL_SENSITIVE = "Official Sensitive"
SECRET = "Secret" # noqa S105
TOP_SECRET = "Top Secret" # noqa S105


MAX_SECURITY_CLASSIFICATION = Classification[env.str("MAX_SECURITY_CLASSIFICATION")]
2 changes: 1 addition & 1 deletion django_app/redbox_app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<header class="govuk-header" role="banner" data-module="govuk-header">

<div class="iai-classification-banner govuk-body">
Up to UK OFFICIAL SENSITIVE documents can be used in this tool
Up to UK {{ security | upper }} documents can be used in this tool
</div>

<div class="govuk-header__container govuk-width-container">
Expand Down
4 changes: 2 additions & 2 deletions django_app/redbox_app/templates/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Ask any question of documents in your Redbox</h1>
<p class="govuk-body-l">Use Artificial Intelligence (AI) to get insights from your personal document set. You can use up to, and including, Official Sensitive documents.</p>
<p class="govuk-body-l">Use Artificial Intelligence (AI) to get insights from your personal document set. You can use up to, and including, {{ security }} documents.</p>
{% if not request.user.is_authenticated %}
<p class="govuk-body">If you have an account, please <a class="govuk-link" href="{{url('sign-in')}}">sign in</a> to get started</p>
{% endif %}
Expand All @@ -26,7 +26,7 @@ <h2 class="govuk-heading-m govuk-!-margin-top-5 govuk-!-padding-top-5">Upload</h
<h2 class="govuk-heading-m govuk-!-margin-top-5 govuk-!-padding-top-5">Chat</h2>
<p class="govuk-body">You can communicate with your Redbox and ask questions of the documents contained within. Use Redbox to unlock deeper insights in the various documents you have uploaded, pulling together summaries of individual or combined documents.</p>
<h2 class="govuk-heading-m govuk-!-margin-top-5 govuk-!-padding-top-5">Secure</h2>
<p class="govuk-body">Redbox is built in our secure and private cloud which enables you to upload, up to, and including, Official Sensitive documents in your Redbox.</p>
<p class="govuk-body">Redbox is built in our secure and private cloud which enables you to upload, up to, and including, {{ security }} documents in your Redbox.</p>

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion django_app/redbox_app/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="govuk-heading-l">{{ pageTitle }}</h1>
{{ govukNotificationBanner(
title="Important",
text_list=[
{"text": "The AI will use all documents you upload. You can use up to, and including, Official Sensitive documents"}
{"text": "The AI will use all documents you upload. You can use up to, and including, " ~ security ~ " documents"}
]
) }}
</div>
Expand Down
7 changes: 3 additions & 4 deletions django_app/tests_playwright/_signin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from playwright.sync_api import Page, expect

logger = logging.getLogger(__name__)
ROOT = Path(__file__).parents[1]
load_dotenv(dotenv_path=ROOT / ".env", override=True)
DJANGO_ROOT = Path(__file__).parents[1]
load_dotenv(dotenv_path=DJANGO_ROOT / ".env", override=True)


def sign_in(page: Page):
Expand All @@ -26,9 +26,8 @@ def sign_in(page: Page):
page.get_by_text("Continue").click()

# Get magic link
django_dir = Path(__file__).parents[2]
command = ["poetry", "run", "python", "manage.py", "show_magiclink_url", email_address]
result = subprocess.run(command, capture_output=True, text=True, cwd=django_dir) # noqa: S603
result = subprocess.run(command, capture_output=True, text=True, cwd=DJANGO_ROOT) # noqa: S603
magic_link = result.stdout.strip()

# Complete sign-in and verify
Expand Down
2 changes: 0 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading