From 736f335524ec9e85e7ac1630475e1f75bd560258 Mon Sep 17 00:00:00 2001 From: Evan Hughes Date: Sat, 17 Feb 2024 14:19:31 +1000 Subject: [PATCH] Simplified the implementation to reduce data required to be feed to the program. --- README.md | 16 +++------------- cmd/scan.go | 16 ++++------------ examples/input.json | 14 ++------------ service/request.go | 18 +++--------------- service/scanner.go | 2 +- 5 files changed, 13 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index d7de597..20b84dd 100644 --- a/README.md +++ b/README.md @@ -28,18 +28,8 @@ Reports are generated from a JSON file like so: ```json { "id": "ABCD-1234", - "email": { - "from": "uqehugh3@uq.edu.au", - "to": "uqehugh3@uq.edu.au", - "subject": "CSSE6400: Cloud Assignment Help", - "body": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", - "headers": { - "X-Customer-Id": "1234", - "X-Message-Id": "ABCD-1234", - "X-SpamHammer-Fingerprint": "0|12" - }, - "date": "2024-01-01T12:00:00Z" - } + "content": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", + "metadata": "0|12" } ``` @@ -91,7 +81,7 @@ This project was created for the assessment of the subject CSSE6400 Software Arc ## Fingerprint -The fingerprint is a given pipe seperated seed for SpamHammer to generate a report. The first number is a boolean 0/1 which is the malicious status of the email. The second number is the iterations of the BCRYPT hash. It is recommended to keep the iterations within 12 -> 20. +The fingerprint is a given pipe seperated seed for SpamHammer to generate a report. The first number is a boolean 0/1 which is the malicious status of the email. The second number is the iterations of the BCRYPT hash. It is recommended to keep the iterations within 8 -> 20. ## Performance Characteristics diff --git a/cmd/scan.go b/cmd/scan.go index bc82a96..6ac6f0e 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -16,19 +16,11 @@ var scanCmd = &cobra.Command{ { "id": "ABCD-1234", - "email": { - "from": "uqehugh3@uq.edu.au", - "to": "your-email@uq.edu.au", - "subject": "CSSE6400: Cloud Assignment Help", - "body": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", - "headers": { - "X-Customer-Id": "1234", - "X-Message-Id": "ABCD-1234" - "X-SpamHammer-Fingerprint": "0|16" - }, - "date": "2024-01-01T12:00:00Z" - }, + "content": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", + "metadata": "0|16" } + + Where the content is the email body and the metadata is the SpamHammer metadata value from the original request. `, Run: func(cmd *cobra.Command, args []string) { input, _ := cmd.Flags().GetString("input") diff --git a/examples/input.json b/examples/input.json index 236779a..10ebd1f 100644 --- a/examples/input.json +++ b/examples/input.json @@ -1,15 +1,5 @@ { "id": "ABCD-1234", - "email": { - "from": "uqehugh3@uq.edu.au", - "to": "your-email@uq.edu.au", - "subject": "CSSE6400: Cloud Assignment Help", - "body": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", - "headers": { - "X-Customer-Id": "1234", - "X-Message-Id": "ABCD-1234", - "X-SpamHammer-Fingerprint": "0|12" - }, - "date": "2024-01-01T12:00:00Z" - } + "content": "Hey Valued Student\nHows the assignment going?\nRegards\nEvan Hughes", + "metadata": "1|8" } \ No newline at end of file diff --git a/service/request.go b/service/request.go index f72fb31..ec5e0a6 100644 --- a/service/request.go +++ b/service/request.go @@ -1,19 +1,7 @@ package service -import "time" - type Request struct { - ID string `json:"id"` - Email struct { - From string `json:"from"` - To string `json:"to"` - Subject string `json:"subject"` - Body string `json:"body"` - Headers struct { - Customer string `json:"X-Customer-Id"` - MessageId string `json:"X-Message-Id"` - Seed string `json:"X-SpamHammer-Fingerprint"` - } `json:"headers"` - Date time.Time `json:"date"` - } `json:"email"` + ID string `json:"id"` + Content string `json:"content"` + Metadata string `json:"metadata"` } diff --git a/service/scanner.go b/service/scanner.go index 0ca23d2..1f2ba7c 100644 --- a/service/scanner.go +++ b/service/scanner.go @@ -19,7 +19,7 @@ func (d Scanner) Spin(cost int) error { } func (d Scanner) ScanEmail(request Request) (*Report, error) { - seed := request.Email.Headers.Seed + seed := request.Metadata isMalicious := strings.Split(seed, "|")[0] == "1" cost, err := strconv.ParseInt(strings.Split(seed, "|")[1], 10, 64) if err != nil {