Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DCSG2900-ThreatTotal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Barstad
DCSG2900-ThreatTotal
Commits
4cbc2104
Commit
4cbc2104
authored
2 years ago
by
Odin K. Henriksen
Browse files
Options
Downloads
Patches
Plain Diff
Commenting and removal of prints.
parent
1a31e98a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/EscalateAnalysis.go
+9
-6
9 additions, 6 deletions
api/EscalateAnalysis.go
with
9 additions
and
6 deletions
api/EscalateAnalysis.go
+
9
−
6
View file @
4cbc2104
...
...
@@ -13,11 +13,12 @@ import (
//Function linked to the escalation to manual analysis button in the frontend. Function sends email to user whom requested manual analysis.
//Function utlizes the gomail package.
//This function has been created with inspiration from https://www.loginradius.com/blog/engineering/sending-emails-with-golang/.
func
EscalateAnalysis
(
url
string
,
result
string
,
token
string
,
hash
string
)
{
email_pwd
:=
os
.
Getenv
(
"email_pwd"
)
email_pwd
:=
os
.
Getenv
(
"email_pwd"
)
//Get service password from ENV.
from
:=
"threattotalv2@gmail.com"
from
:=
"threattotalv2@gmail.com"
//Address to send email from.
to
:=
getUserEmail
(
token
)
//Gets the email of the user.
...
...
@@ -52,6 +53,7 @@ func EscalateAnalysis(url string, result string, token string, hash string) {
// Now send E-Mail
if
err
:=
d
.
DialAndSend
(
m
);
err
!=
nil
{
fmt
.
Println
(
err
)
logging
.
Logerror
(
err
,
"Error sending email - EscalateManualAnalysis."
)
}
}
...
...
@@ -68,17 +70,18 @@ func getUserEmail(hash string) (email string) {
}
}
responseBytes
,
err
:=
json
.
Marshal
(
value
)
//Marshal data
responseBytes
,
err
:=
json
.
Marshal
(
value
)
//Marshal data
if
err
!=
nil
{
fmt
.
Println
(
err
)
logging
.
Logerror
(
err
,
"Error marshalling data"
)
}
var
test
[]
byte
var
JWTdata
utils
.
IdAndJwt
err
=
json
.
Unmarshal
(
responseBytes
,
&
test
)
//Unmarshal data
err
=
json
.
Unmarshal
(
responseBytes
,
&
test
)
//Unmarshal data
json
.
Unmarshal
(
test
,
&
JWTdata
)
email
=
fmt
.
Sprintf
(
"%s"
,
JWTdata
.
Claims
[
"email"
])
//Set the email
return
email
//Return the email.
email
=
fmt
.
Sprintf
(
"%s"
,
JWTdata
.
Claims
[
"email"
])
//Set the email
return
email
//Return the email.
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment