Skip to content

Commit

Permalink
Merge pull request #836 from k2io/dev
Browse files Browse the repository at this point in the history
Post security configuration on UI
  • Loading branch information
nr-swilloughby authored Dec 14, 2023
2 parents 7d91b51 + 4c3f82f commit 02cae21
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v3/integrations/nrsecurityagent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/newrelic/csec-go-agent v0.5.1
github.com/newrelic/go-agent/v3 v3.28.1
github.com/newrelic/go-agent/v3 v3.29.0
github.com/newrelic/go-agent/v3/integrations/nrsqlite3 v1.2.0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
1 change: 1 addition & 0 deletions v3/integrations/nrsecurityagent/nrsecurityagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func InitSecurityAgent(app *newrelic.Application, opts ...ConfigOption) error {
if !isValid {
return fmt.Errorf("Newrelic application value cannot be read; did you call newrelic.NewApplication?")
}
app.UpdateSecurityConfig(c.Security)
if !appConfig.HighSecurity && isSecurityAgentEnabled() {
secureAgent := securityAgent.InitSecurityAgent(c.Security, appConfig.AppName, appConfig.License, appConfig.Logger.DebugEnabled())
app.RegisterSecurityAgent(secureAgent)
Expand Down
2 changes: 2 additions & 0 deletions v3/newrelic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ type Config struct {
// This list of ignored prefixes itself is not reported outside the agent.
IgnoredPrefixes []string
}
// Security is used to post security configuration on UI.
Security interface{} `json:"Security,omitempty"`
}

// CodeLevelMetricsScope is a bit-encoded value. Each such value describes
Expand Down
7 changes: 7 additions & 0 deletions v3/newrelic/secure_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func (app *Application) RegisterSecurityAgent(s securityAgent) {
}
}

func (app *Application) UpdateSecurityConfig(s interface{}) {
if app == nil || app.app == nil {
return
}
app.app.config.Config.Security = s
}

func getLinkedMetaData(app *app) map[string]string {
runningAppData := make(map[string]string)
if app != nil && app.run != nil {
Expand Down

0 comments on commit 02cae21

Please sign in to comment.