Skip to content

Commit

Permalink
feat: distribution optional
Browse files Browse the repository at this point in the history
  • Loading branch information
anasmuhmd committed Dec 15, 2024
1 parent 4b112e2 commit a762cf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/misp/client/misp_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type AddEventReportRequest struct {
EventId string `json:"event_id"`
Name string `json:"name"`
Content string `json:"content"`
Distribution string `json:"distribution"`
Distribution *string `json:"distribution"`
SharingGroupId *string `json:"sharing_group_id"`
Timestamp *string `json:"timestamp"`
Deleted bool `json:"deleted"`
Expand Down
23 changes: 13 additions & 10 deletions internal/misp/publish_misp_event_reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ func makeMispEventReportsPublisher(loader ClientLoaderFn) *plugin.Publisher {
Constraints: constraint.RequiredMeaningful,
},
{
Name: "distribution",
Type: cty.String,
Constraints: constraint.RequiredMeaningful,
Name: "distribution",
Type: cty.String,
OneOf: []cty.Value{
cty.StringVal("0"),
cty.StringVal("1"),
Expand Down Expand Up @@ -123,13 +122,17 @@ func publishEventReport(loader ClientLoaderFn) plugin.PublishFunc {

timestamp := fmt.Sprintf("%d", time.Now().Unix())
report := client.AddEventReportRequest{
Uuid: uuid.New().String(),
EventId: params.Args.GetAttrVal("event_id").AsString(),
Name: params.Args.GetAttrVal("name").AsString(),
Content: buff.String(),
Distribution: params.Args.GetAttrVal("distribution").AsString(),
Timestamp: &timestamp,
Deleted: false,
Uuid: uuid.New().String(),
EventId: params.Args.GetAttrVal("event_id").AsString(),
Name: params.Args.GetAttrVal("name").AsString(),
Content: buff.String(),
Timestamp: &timestamp,
Deleted: false,
}
distribution := params.Args.GetAttrVal("distribution")
if !distribution.IsNull() {
distributionStr := distribution.AsString()
report.Distribution = &distributionStr
}
sharingGroupId := params.Args.GetAttrVal("sharing_group_id")
if !sharingGroupId.IsNull() {
Expand Down

0 comments on commit a762cf7

Please sign in to comment.