Skip to content
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
38 changes: 17 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
[![Build status](https://ci.appveyor.com/api/projects/status/8kjm4utaiq58ok01/branch/master?svg=true)](https://ci.appveyor.com/project/SimonCropp/australianprotectivemarkings)
[![NuGet Status](https://img.shields.io/nuget/v/AustralianProtectiveMarkings.svg)](https://www.nuget.org/packages/AustralianProtectiveMarkings/)

A dotnet representation of Protective Markings defined in the [Australian Protective Security Policy Framework](https://www.protectivesecurity.gov.au/publications-library/policy-8-classification-system)
A dotnet representation of Protective Markings defined in the [Australian Government Email Protective Marking Standard](https://www.protectivesecurity.gov.au/system/files/2024-10/australian-government-email-protective-marking-standard.pdf)

**See [Milestones](../../milestones?state=closed) for release notes.**

Spec:

* [PSPF: Sensitive and classified information](https://www.protectivesecurity.gov.au/system/files/2023-08/annex-f-policy-8-classification-system-pspf.pdf)
* [PSPF: Sensitive and classified information - Annex F (email clarifications)](https://www.protectivesecurity.gov.au/system/files/2023-08/annex-f-policy-8-classification-system-pspf.pdf)

* [Australian Government Email Protective Marking Standard](https://www.protectivesecurity.gov.au/system/files/2024-10/australian-government-email-protective-marking-standard.pdf)

## NuGet package

Expand All @@ -36,16 +34,15 @@ All string members follow the convention of:

Converts a protected marking to text that should be appended to an email subject line.

See "Subject Field Marking" in [PSPF: Sensitive and classified information - Annex F (email clarifications)](https://www.protectivesecurity.gov.au/system/files/2023-08/annex-f-policy-8-classification-system-pspf.pdf)
See [6.1. Subject Field Marking](https://www.protectivesecurity.gov.au/system/files/2024-10/australian-government-email-protective-marking-standard.pdf#page=5)

> In this syntax, the protective marking is placed in the subject field of the message (RFC5322 ‘Subject’). As per
> RFC5322, an Internet email message can have at most one subject field. Allowing for no more than one email protective
> marking in the subject line minimises confusion and potential conflict.
> RFC5322, an Internet email message can have at most one subject field. Allowing for no more than one email
> protective marking in the subject line minimises confusion and potential conflict.
>
> A Subject Field Marking is less sophisticated than an Internet Message Header Extension as it is possible to
> manipulate an email’s subject during message generation or transport. However, it is easy to apply as a human
> user can construct (and interpret) the protective marking without the need for additional tools.

> manipulate an email’s subject during message generation or transport. However, it is easy to apply as a human user
> can construct (and interpret) the protective marking without the need for additional tools.

### Minimum content

Expand Down Expand Up @@ -117,17 +114,16 @@ Results in:

Converts a protected marking to text that should be added as the value opf the `X-Protective-Marking` email header.

See "Internet Message Header Extension" in [PSPF: Sensitive and classified information - Annex F (email clarifications)](https://www.protectivesecurity.gov.au/system/files/2022-12/annex-f-pspf-policy8-sensitive-and-classified-information.pdf)
See [6.2. Internet Message Header Extension ](https://www.protectivesecurity.gov.au/system/files/2024-10/australian-government-email-protective-marking-standard.pdf#page=5)

> In this syntax, the protective marking is carried as a custom Internet Message Header Extension
> ‘X-Protective-Marking’. Allowing for no more than one ‘X-Protective-Marking’ field minimises confusion and potential
> conflict.
> ‘X-Protective-Marking’. Allowing for no more than one ‘X-Protective-Marking’ field minimises confusion and
> potential conflict.
>
> Using an Internet Message Header Extension is more sophisticated than a Subject Field Marking. It is designed for
> construction and parsing by email agents (clients, gateways and servers) as they have accessto internet message
> construction and parsing by email agents (clients, gateways and servers) as they have access to internet message
> headers. In this way a richer syntax can be used and email agents can perform more complex handling based on
> the protective marking

> the protective marking.

### Minimum content

Expand All @@ -148,7 +144,7 @@ Results in:
<!-- snippet: Samples.RenderEmailHeaderMinimum.verified.txt -->
<a id='snippet-Samples.RenderEmailHeaderMinimum.verified.txt'></a>
```txt
VER=2018.4, NS=gov.au, SEC=TOP-SECRET
VER=2024.1, NS=gov.au, SEC=TOP-SECRET
```
<sup><a href='/src/Tests/Samples.RenderEmailHeaderMinimum.verified.txt#L1-L1' title='Snippet source file'>snippet source</a> | <a href='#snippet-Samples.RenderEmailHeaderMinimum.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Expand Down Expand Up @@ -189,7 +185,7 @@ Results in:
<!-- snippet: Samples.RenderEmailHeaderFull.verified.txt -->
<a id='snippet-Samples.RenderEmailHeaderFull.verified.txt'></a>
```txt
VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
```
<sup><a href='/src/Tests/Samples.RenderEmailHeaderFull.verified.txt#L1-L1' title='Snippet source file'>snippet source</a> | <a href='#snippet-Samples.RenderEmailHeaderFull.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Expand Down Expand Up @@ -233,7 +229,7 @@ Results in:
To: to@mail.com,
Subject: The subject [SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege],
Headers: {
X-Protective-Marking: VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege
X-Protective-Marking: VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege
},
IsBodyHtml: false,
Body: The body
Expand Down Expand Up @@ -339,7 +335,7 @@ var protectiveMarking = Parser.ParseProtectiveMarking("SEC=OFFICIAL:Sensitive");
<!-- snippet: ParseEmailHeaderFull -->
<a id='snippet-ParseEmailHeaderFull'></a>
```cs
var protectiveMarking = Parser.ParseProtectiveMarking("VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:CodeWord, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com");
var protectiveMarking = Parser.ParseProtectiveMarking("VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:CodeWord, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com");
```
<sup><a href='/src/Tests/Samples.cs#L178-L182' title='Snippet source file'>snippet source</a> | <a href='#snippet-ParseEmailHeaderFull' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Expand Down Expand Up @@ -391,7 +387,7 @@ For readability, newlines are allowed to delineate key value pairs:
```cs
var protectiveMarking = Parser.ParseProtectiveMarking(
"""
VER=2018.4,
VER=2024.1,
NS=gov.au,
SEC=TOP-SECRET,
CAVEAT=C:CodeWord,
Expand Down
2 changes: 1 addition & 1 deletion src/AustralianProtectiveMarkings/Renderer_Email.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static string RenderEmailSubjectSuffix(this ProtectiveMarking marking)

public static string RenderEmailHeader(this ProtectiveMarking marking)
{
var builder = new StringBuilder("VER=2018.4, NS=gov.au, ");
var builder = new StringBuilder("VER=2024.1, NS=gov.au, ");
RenderMailClassification(marking, builder);
RenderMailCaveats(marking, builder);
RenderMailExpiry(marking, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To: to@mail.com,
Subject: The subject [SEC=TOP-SECRET],
Headers: {
X-Protective-Marking: VER=2018.4, NS=gov.au, SEC=TOP-SECRET
X-Protective-Marking: VER=2024.1, NS=gov.au, SEC=TOP-SECRET
},
IsBodyHtml: false,
Body: The body
Expand Down
10 changes: 5 additions & 5 deletions src/Tests/OfficeDocHelperTests.Patch.verified.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
Tests.docs.correctProps.docx:
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2018.4, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2024.1, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
Tests.docs.noProps.docx:
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2018.4, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2024.1, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
Tests.docs.sample.pptx:
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2018.4, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2024.1, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
Tests.docs.sample.xlsx:
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2018.4, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2024.1, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>,
Tests.docs.withProps.docx:
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2018.4, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>
<op:property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="X-Protective-Marking" xmlns:op="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"><vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">VER=2024.1, NS=gov.au, SEC=PROTECTED</vt:lpwstr></op:property>
}
10 changes: 5 additions & 5 deletions src/Tests/ParserTests.Simple.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@
TOPSECRET: TopSecret,
Unofficial: Unofficial,
UNOFFICIAL: Unofficial,
VER=2018.4: {
VER=2024.1: {
Type: Exception,
Message: A single security 'SEC' must be defined. Input: VER=2018.4
Message: A single security 'SEC' must be defined. Input: VER=2024.1
},
VER=2018.4, NS=gov.au: {
VER=2024.1, NS=gov.au: {
Type: Exception,
Message: A single security 'SEC' must be defined. Input: VER=2018.4, NS=gov.au
Message: A single security 'SEC' must be defined. Input: VER=2024.1, NS=gov.au
},
VER=2018.4, NS=gov.au, SEC=TOP-SECRET: TopSecret
VER=2024.1, NS=gov.au, SEC=TOP-SECRET: TopSecret
}
6 changes: 3 additions & 3 deletions src/Tests/ParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public Task Simple()
{
var list = new List<string>
{
"VER=2018.4",
"VER=2018.4, NS=gov.au",
"VER=2018.4, NS=gov.au, SEC=TOP-SECRET",
"VER=2024.1",
"VER=2024.1, NS=gov.au",
"VER=2024.1, NS=gov.au, SEC=TOP-SECRET",
"SEC=TOP-SECRET",
"SEC= TOP-SECRET",
"SEC=OFFICIAL:Sensitive",
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/RendererTests.RenderEmailHeader.verified.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:usa caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:usa caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VER=2018.4, NS=gov.au, SEC=SECRET, EXPIRES=2020-10-01T00:00:00.0000001, DOWNTO=OFFICIAL
VER=2024.1, NS=gov.au, SEC=SECRET, EXPIRES=2020-10-01T00:00:00.0000001, DOWNTO=OFFICIAL
2 changes: 1 addition & 1 deletion src/Tests/RendererTests.RenderEmailHeaderMin.verified.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VER=2018.4, NS=gov.au, SEC=SECRET
VER=2024.1, NS=gov.au, SEC=SECRET
2 changes: 1 addition & 1 deletion src/Tests/Samples.ApplyProtectiveMarkings.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To: to@mail.com,
Subject: The subject [SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege],
Headers: {
X-Protective-Marking: VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege
X-Protective-Marking: VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=SH:CABINET, CAVEAT=RI:REL AFG, ACCESS=Legal-Privilege
},
IsBodyHtml: false,
Body: The body
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Samples.RenderEmailHeaderFull.verified.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:LOBSTER, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com
2 changes: 1 addition & 1 deletion src/Tests/Samples.RenderEmailHeaderMinimum.verified.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VER=2018.4, NS=gov.au, SEC=TOP-SECRET
VER=2024.1, NS=gov.au, SEC=TOP-SECRET
6 changes: 3 additions & 3 deletions src/Tests/Samples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Task ParseEmailHeaderMinimum()
{
#region ParseEmailHeaderMinimum

var protectiveMarking = Parser.ParseProtectiveMarking("VER=2018.4, NS=gov.au, SEC=OFFICIAL:Sensitive");
var protectiveMarking = Parser.ParseProtectiveMarking("VER=2024.1, NS=gov.au, SEC=OFFICIAL:Sensitive");

#endregion

Expand Down Expand Up @@ -177,7 +177,7 @@ public Task ParseEmailHeaderFull()
{
#region ParseEmailHeaderFull

var protectiveMarking = Parser.ParseProtectiveMarking("VER=2018.4, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:CodeWord, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com");
var protectiveMarking = Parser.ParseProtectiveMarking("VER=2024.1, NS=gov.au, SEC=TOP-SECRET, CAVEAT=C:CodeWord, CAVEAT=FG:USA caveat, CAVEAT=RI:AGAO, CAVEAT=SH:CABINET, CAVEAT=SH:EXCLUSIVE-FOR person, CAVEAT=RI:REL AFG/DZA, EXPIRES=2020-10-01, DOWNTO=OFFICIAL, ACCESS=Legal-Privilege, NOTE=the comments, ORIGIN=a@b.com");

#endregion

Expand Down Expand Up @@ -217,7 +217,7 @@ public Task ParseEmailHeaderFullNewlines()

var protectiveMarking = Parser.ParseProtectiveMarking(
"""
VER=2018.4,
VER=2024.1,
NS=gov.au,
SEC=TOP-SECRET,
CAVEAT=C:CodeWord,
Expand Down