Skip to content

Commit

Permalink
Simplified the implementation to reduce data required to be feed to t…
Browse files Browse the repository at this point in the history
…he program.
  • Loading branch information
wisebaldone committed Feb 17, 2024
1 parent b5cb22d commit 736f335
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 53 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,8 @@ Reports are generated from a JSON file like so:
```json
{
"id": "ABCD-1234",
"email": {
"from": "[email protected]",
"to": "[email protected]",
"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"
}
```

Expand Down Expand Up @@ -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

Expand Down
16 changes: 4 additions & 12 deletions cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ var scanCmd = &cobra.Command{
{
"id": "ABCD-1234",
"email": {
"from": "[email protected]",
"to": "[email protected]",
"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")
Expand Down
14 changes: 2 additions & 12 deletions examples/input.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"id": "ABCD-1234",
"email": {
"from": "[email protected]",
"to": "[email protected]",
"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"
}
18 changes: 3 additions & 15 deletions service/request.go
Original file line number Diff line number Diff line change
@@ -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"`
}
2 changes: 1 addition & 1 deletion service/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 736f335

Please sign in to comment.