Skip to content

Commit

Permalink
add communication messages
Browse files Browse the repository at this point in the history
  • Loading branch information
noboruma committed Jan 17, 2025
1 parent e1632ad commit 8f99f2d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deepfence_agent/plugins/yara-rules
Submodule yara-rules updated 1 files
+1 −1 build-timestamp
47 changes: 47 additions & 0 deletions deepfence_utils/threatintel/coms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package threatintel

import (
"encoding/json"
"errors"
"io"
"net/http"
)

type Message struct {
ID int `json:"id"`
Content string `json:"content"`
UpdatedAt int64 `json:"updated_at"`
}

type Coms struct {
UpdatedAt int64 `json:"updated_at"`
Messages []Message `json:"messages"`
}

const comsURL = "https://deepfence-coms.s3.us-east-2.amazonaws.com/ThreatMapper/coms.json"

func GetCommunicationMessages() (Coms, error) {

resp, err := http.Get(comsURL)
if err != nil {
return Coms{}, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return Coms{}, errors.New("Failed reaching data")
}

body, err := io.ReadAll(resp.Body)
if err != nil {
return Coms{}, err
}

var data Coms
err = json.Unmarshal(body, &data)
if err != nil {
return Coms{}, err
}

return data, nil
}

0 comments on commit 8f99f2d

Please sign in to comment.