mirror of
https://github.com/gophish/gophish
synced 2024-11-15 00:37:14 +00:00
Updated validation function
This commit is contained in:
parent
ad20017981
commit
b02670d207
2 changed files with 15 additions and 12 deletions
|
@ -22,23 +22,26 @@ type Attachment struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateAttachment ensures that the provided attachment uses the supported template variables correctly.
|
// ValidateAttachment ensures that the provided attachment uses the supported template variables correctly.
|
||||||
func (a Attachment) ValidateAttachment() error {
|
func (a Attachment) Validate() error {
|
||||||
|
|
||||||
ptx := PhishingTemplateContext{
|
vc := ValidationContext{
|
||||||
|
FromAddress: "foo@bar.com",
|
||||||
|
BaseURL: "http://example.com",
|
||||||
|
}
|
||||||
|
td := Result{
|
||||||
BaseRecipient: BaseRecipient{
|
BaseRecipient: BaseRecipient{
|
||||||
|
Email: "foo@bar.com",
|
||||||
FirstName: "Foo",
|
FirstName: "Foo",
|
||||||
LastName: "Bar",
|
LastName: "Bar",
|
||||||
Email: "foo@bar.com",
|
Position: "Test",
|
||||||
},
|
},
|
||||||
BaseURL: "http://testurl.com",
|
RId: "123456",
|
||||||
URL: "http://testurl.com/?rid=1234567",
|
|
||||||
TrackingURL: "http://testurl.local/track?rid=1234567",
|
|
||||||
Tracker: "<img alt='' style='display: none' src='http://testurl.local/track?rid=1234567'/>",
|
|
||||||
From: "Foobus Barbus",
|
|
||||||
RId: "1234567",
|
|
||||||
}
|
}
|
||||||
|
ptx, err := NewPhishingTemplateContext(vc, td.BaseRecipient, td.RId)
|
||||||
_, err := a.ApplyTemplate(ptx)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = a.ApplyTemplate(ptx)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (t *Template) Validate() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, a := range t.Attachments {
|
for _, a := range t.Attachments {
|
||||||
if err := a.ValidateAttachment(); err != nil {
|
if err := a.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue