mirror of
https://github.com/gophish/gophish
synced 2024-11-14 16:27:23 +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.
|
||||
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{
|
||||
Email: "foo@bar.com",
|
||||
FirstName: "Foo",
|
||||
LastName: "Bar",
|
||||
Email: "foo@bar.com",
|
||||
Position: "Test",
|
||||
},
|
||||
BaseURL: "http://testurl.com",
|
||||
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",
|
||||
RId: "123456",
|
||||
}
|
||||
|
||||
_, err := a.ApplyTemplate(ptx)
|
||||
ptx, err := NewPhishingTemplateContext(vc, td.BaseRecipient, td.RId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = a.ApplyTemplate(ptx)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ func (t *Template) Validate() error {
|
|||
return err
|
||||
}
|
||||
for _, a := range t.Attachments {
|
||||
if err := a.ValidateAttachment(); err != nil {
|
||||
if err := a.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue