Skip to content

Commit

Permalink
Merge pull request #75 from newrelic/ci_cd
Browse files Browse the repository at this point in the history
CI-CD integration
  • Loading branch information
aayush-ap authored Dec 11, 2024
2 parents 6d4d2d9 + 6ff8bae commit 9765399
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions security_config/global_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@ func (info *Info_struct) SetscanControllersIastLoadInterval(iastLoadInterval int
info.security.ScanControllers.IastScanRequestRateLimit = iastLoadInterval
}

func (info *Info_struct) ScanInstanceCount() int {
return info.security.ScanControllers.ScanInstanceCount
}
func (info *Info_struct) SetScanInstanceCount(scanInstanceCount int) {
info.security.ScanControllers.ScanInstanceCount = scanInstanceCount
}

func (info *Info_struct) GetIastTestIdentifier() string {
return info.security.IastTestIdentifier
}

func (info *Info_struct) GetApiData() []any {
urlmappings := []any{}

Expand Down
2 changes: 2 additions & 0 deletions security_config/secure_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Security struct {
Enabled bool `json:"enabled"`
Mode string `json:"mode"`
Validator_service_url string `json:"validator_service_url"`
IastTestIdentifier string `json:"iast_test_identifier" yaml:"iast_test_identifier"`
Agent struct {
Enabled bool `json:"enabled"`
} `json:"agent"`
Expand Down Expand Up @@ -53,6 +54,7 @@ type Security struct {
} `yaml:"scan_schedule"`
ScanControllers struct {
IastScanRequestRateLimit int `yaml:"iast_scan_request_rate_limit"`
ScanInstanceCount int `yaml:"scan_instance_count"`
} `yaml:"scan_controllers"`
}

Expand Down
1 change: 1 addition & 0 deletions security_event_generation/event_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func SendSecHealthCheck() {
hc.WebSocketConnectionStats = secConfig.GlobalInfo.WebSocketConnectionStats
hc.IastReplayRequest = secConfig.GlobalInfo.IastReplayRequest
hc.EventStats = secConfig.GlobalInfo.EventStats
hc.IastTestIdentifier = secConfig.GlobalInfo.GetIastTestIdentifier()

hc.ProcStartTime = secConfig.GlobalInfo.ApplicationInfo.GetStarttimestr().Unix() * 1000
hc.TrafficStartedTime = secConfig.GlobalInfo.ApplicationInfo.GetTrafficStartedTime()
Expand Down
1 change: 1 addition & 0 deletions security_event_generation/event_generation_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type healthcheck struct {
ProcStartTime int64 `json:"procStartTime"`
TrafficStartedTime int64 `json:"trafficStartedTime"`
ScanStartTime int64 `json:"scanStartTime"`
IastTestIdentifier string `json:"iastTestIdentifer"`
}

type ThreadPoolStats struct {
Expand Down
7 changes: 7 additions & 0 deletions security_handlers/web_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ func getConnectionHeader() http.Header {
"NR-CSEC-PROCESS-START-TIME": []string{secUtils.Int64ToString(secConfig.GlobalInfo.ApplicationInfo.GetStarttimestr().Unix() * 1000)},
}

if env := secConfig.GlobalInfo.GetIastTestIdentifier(); env != "" {
connectionHeader.Add("NR-CSEC-IAST-TEST-IDENTIFIER", env)
connectionHeader.Add("NR-CSEC-IAST-SCAN-INSTANCE-COUNT", secUtils.IntToString(1))
} else {
connectionHeader.Add("NR-CSEC-IAST-SCAN-INSTANCE-COUNT", secUtils.IntToString(secConfig.GlobalInfo.ScanInstanceCount()))
}

printConnectionHeader(connectionHeader)
return connectionHeader
}
Expand Down

0 comments on commit 9765399

Please sign in to comment.