Projects STRLCPY gophish Commits 0c5925ae
🤬
  • Fixed template validation to better support the all the possible template tags. Fixes #1189

  • Loading...
  • Jordan Wright committed 6 years ago
    0c5925ae
    1 parent 159ea126
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    models/template.go
    skipped 35 lines
    36 36   }
    37 37   // Test that the variables used in the template
    38 38   // validate with no issues
    39  - td := struct {
    40  - Result
    41  - URL string
    42  - TrackingURL string
    43  - Tracker string
    44  - From string
    45  - }{
    46  - Result{
    47  - BaseRecipient: BaseRecipient{
    48  - Email: "[email protected]",
    49  - FirstName: "Foo",
    50  - LastName: "Bar",
    51  - Position: "Test",
    52  - },
     39 + vc := ValidationContext{
     40 + FromAddress: "[email protected]",
     41 + BaseURL: "http://example.com",
     42 + }
     43 + td := Result{
     44 + BaseRecipient: BaseRecipient{
     45 + Email: "[email protected]",
     46 + FirstName: "Foo",
     47 + LastName: "Bar",
     48 + Position: "Test",
    53 49   },
    54  - "http://foo.bar",
    55  - "http://foo.bar/track",
    56  - "<img src='http://foo.bar/track",
    57  - "John Doe <[email protected]>",
     50 + RId: "123456",
     51 + }
     52 + ptx, err := NewPhishingTemplateContext(vc, td.BaseRecipient, td.RId)
     53 + if err != nil {
     54 + return err
    58 55   }
    59  - _, err := ExecuteTemplate(t.HTML, td)
     56 + _, err = ExecuteTemplate(t.HTML, ptx)
    60 57   if err != nil {
    61 58   return err
    62 59   }
    63  - _, err = ExecuteTemplate(t.Text, td)
     60 + _, err = ExecuteTemplate(t.Text, ptx)
    64 61   if err != nil {
    65 62   return err
    66 63   }
    skipped 143 lines
  • ■ ■ ■ ■ ■ ■
    models/template_context.go
    skipped 14 lines
    15 15   getBaseURL() string
    16 16  }
    17 17   
     18 +// ValidationContext is used for validating templates and pages
     19 +type ValidationContext struct {
     20 + FromAddress string
     21 + BaseURL string
     22 +}
     23 + 
     24 +func (vc ValidationContext) getFromAddress() string {
     25 + return vc.FromAddress
     26 +}
     27 + 
     28 +func (vc ValidationContext) getBaseURL() string {
     29 + return vc.BaseURL
     30 +}
     31 + 
    18 32  // PhishingTemplateContext is the context that is sent to any template, such
    19 33  // as the email or landing page content.
    20 34  type PhishingTemplateContext struct {
    skipped 63 lines
Please wait...
Page is in error, reload to recover