mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-10-08 16:31:20 +02:00
added scripts feature
Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
37 files changed
+4319
-82
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
CAMPAIGN_SCRIPT_TABLE = "campaign_scripts"
|
||||
)
|
||||
|
||||
// CampaignScript is a gorm data model.
|
||||
// It is a junction table for the campaign to script many to many relationship
|
||||
// and stores the per script configuration (events and data level).
|
||||
// It mirrors CampaignWebhook so scripts are configured on a campaign the
|
||||
// same way webhooks are.
|
||||
type CampaignScript struct {
|
||||
CampaignID *uuid.UUID `gorm:"not null;index;type:uuid;uniqueIndex:idx_campaign_script;primaryKey;"`
|
||||
Campaign *Campaign
|
||||
|
||||
ScriptID *uuid.UUID `gorm:"not null;index;type:uuid;uniqueIndex:idx_campaign_script;primaryKey;"`
|
||||
Script *Script
|
||||
|
||||
// scriptincludedata is the data level handed to the script.
|
||||
// values: "none", "basic", "full"
|
||||
ScriptIncludeData string `gorm:"not null;default:'full'"`
|
||||
|
||||
// scriptevents is a binary format storing selected events as bits.
|
||||
// 0 = all events (default). Uses the same bit map as webhooks
|
||||
// (data.WebhookEventToBit) so the two features subscribe identically.
|
||||
ScriptEvents int `gorm:"not null;default:0"`
|
||||
}
|
||||
|
||||
func (CampaignScript) TableName() string {
|
||||
return CAMPAIGN_SCRIPT_TABLE
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const (
|
||||
SCRIPT_TABLE = "scripts"
|
||||
)
|
||||
|
||||
// Script is a gorm data model for scripts.
|
||||
// An script holds a JavaScript program that runs when a subscribed
|
||||
// campaign event fires. It is the scripting counterpart to a webhook.
|
||||
type Script struct {
|
||||
ID *uuid.UUID `gorm:"primary_key;not null;unique;type:uuid"`
|
||||
CreatedAt *time.Time `gorm:"not null;index;"`
|
||||
UpdatedAt *time.Time `gorm:"not null;index;"`
|
||||
CompanyID *uuid.UUID `gorm:"uniqueIndex:idx_scripts_unique_name_and_company_id;type:uuid"`
|
||||
Name string `gorm:"not null;uniqueIndex:idx_scripts_unique_name_and_company_id;"`
|
||||
Script string `gorm:"not null;"`
|
||||
}
|
||||
|
||||
func (e *Script) Migrate(db *gorm.DB) error {
|
||||
// SQLITE
|
||||
// ensure name + company id is unique
|
||||
return UniqueIndexNameAndNullCompanyID(db, SCRIPT_TABLE)
|
||||
}
|
||||
|
||||
func (Script) TableName() string {
|
||||
return SCRIPT_TABLE
|
||||
}
|
||||
Reference in new issue
Block a user