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 6 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_REPR,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to use an enum, we'd want 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_REPR,
}
)
return env
17 changes: 17 additions & 0 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,20 @@
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/

MAX_SECURITY_CLASSIFICATION = env.str("MAX_SECURITY_CLASSIFICATION")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make this an enum:

class Classification(enum.StrEnum):
    OFFICIAL = "Official"
    OFFICIAL_SENSITIVE = "Official Sensitive"
    ...
    
MAX_SECURITY_CLASSIFICATION = Classification[env.str("MAX_SECURITY_CLASSIFICATION")]

We'd need to use underscores rather than dashes in the names for them, of course.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - would we want a default value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine withw/without an enum. r.e. default, we want it to fall over if they haven't set it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about it and decided to use the enum.


match MAX_SECURITY_CLASSIFICATION:
case "OFFICIAL":
MAX_SECURITY_REPR = "Official"
case "OFFICIAL-SENSITIVE":
MAX_SECURITY_REPR = "Official Sensitive"
case "SECRET":
MAX_SECURITY_REPR = "Secret"
case "TOP-SECRET":
MAX_SECURITY_REPR = "Top Secret"
case _:
raise Exception(f"Unknown MAX_SECURITY_CLASSIFICATION of {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
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