From 2c9f613c2a0bcc1ccb2a422dfd2f584fb62392e7 Mon Sep 17 00:00:00 2001 From: Tim Thacker Date: Thu, 19 Feb 2026 11:06:44 +1100 Subject: [PATCH] feat: add camelCase json tags to all model structs Add json struct tags alongside existing yaml tags to all model types. This enables proper JSON serialization with camelCase field names while preserving snake_case yaml serialization for config files. Co-Authored-By: Claude Opus 4.6 --- pkg/models/code.go | 18 +++++++-------- pkg/models/dependencies.go | 16 ++++++------- pkg/models/integrations.go | 46 +++++++++++++++++++------------------- pkg/models/models.go | 24 ++++++++++---------- pkg/models/secrets.go | 34 ++++++++++++++-------------- 5 files changed, 69 insertions(+), 69 deletions(-) diff --git a/pkg/models/code.go b/pkg/models/code.go index c563400..ff053f1 100644 --- a/pkg/models/code.go +++ b/pkg/models/code.go @@ -1,22 +1,22 @@ package models type Code struct { - EnableFailBuilds *bool `yaml:"enable_fail_builds,omitempty"` - Ignore []CodeIgnore `yaml:"ignore,omitempty"` + EnableFailBuilds *bool `json:"enableFailBuilds,omitempty" yaml:"enable_fail_builds,omitempty"` + Ignore []CodeIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` } type CodeIgnore struct { - Reason string `yaml:"reason,omitempty"` - Expiry string `yaml:"expiry,omitempty"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` + Expiry string `json:"expiry,omitempty" yaml:"expiry,omitempty"` // matchers - CWEs []int `yaml:"cwes,omitempty"` - RuleIDs []string `yaml:"rule_ids,omitempty"` - Dirs []string `yaml:"dirs,omitempty"` + CWEs []int `json:"cwes,omitempty" yaml:"cwes,omitempty"` + RuleIDs []string `json:"ruleIds,omitempty" yaml:"rule_ids,omitempty"` + Dirs []string `json:"dirs,omitempty" yaml:"dirs,omitempty"` // global config only - Repositories []string `yaml:"repositories,omitempty"` + Repositories []string `json:"repositories,omitempty" yaml:"repositories,omitempty"` // TODO deprecate - Paths []string `yaml:"paths,omitempty"` + Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"` } diff --git a/pkg/models/dependencies.go b/pkg/models/dependencies.go index a9ca680..84663ce 100644 --- a/pkg/models/dependencies.go +++ b/pkg/models/dependencies.go @@ -1,21 +1,21 @@ package models type Dependencies struct { - EnableFailBuilds *bool `yaml:"enable_fail_builds,omitempty"` - Ignore []DependenciesIgnore `yaml:"ignore,omitempty"` + EnableFailBuilds *bool `json:"enableFailBuilds,omitempty" yaml:"enable_fail_builds,omitempty"` + Ignore []DependenciesIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` } type DependenciesIgnore struct { - Reason string `yaml:"reason,omitempty"` - Expiry string `yaml:"expiry,omitempty"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` + Expiry string `json:"expiry,omitempty" yaml:"expiry,omitempty"` // matchers - CVEs []string `yaml:"cves,omitempty"` - Dirs []string `yaml:"dirs,omitempty"` + CVEs []string `json:"cves,omitempty" yaml:"cves,omitempty"` + Dirs []string `json:"dirs,omitempty" yaml:"dirs,omitempty"` // global config only - Repositories []string `yaml:"repositories,omitempty"` + Repositories []string `json:"repositories,omitempty" yaml:"repositories,omitempty"` // TODO deprecate - Paths []string `yaml:"paths,omitempty"` + Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"` } diff --git a/pkg/models/integrations.go b/pkg/models/integrations.go index a90de00..0e87c22 100644 --- a/pkg/models/integrations.go +++ b/pkg/models/integrations.go @@ -1,38 +1,38 @@ package models type Integrations struct { - Jira *Jira `yaml:"jira,omitempty"` + Jira *Jira `json:"jira,omitempty" yaml:"jira,omitempty"` } type Jira struct { - Disabled bool `yaml:"disabled,omitempty"` - Enabled *bool `yaml:"enabled,omitempty"` - ProjectKey string `yaml:"project_key,omitempty"` - IssueType string `yaml:"issue_type,omitempty"` - SeverityThreshold string `yaml:"severity_threshold,omitempty"` - PriorityThreshold string `yaml:"priority_threshold,omitempty"` - OnFixTransition string `yaml:"on_fix_transition,omitempty"` - CommentOnClose *bool `yaml:"comment_on_close,omitempty"` - Labels []string `yaml:"labels,omitempty"` - TitleTemplate string `yaml:"title_template,omitempty"` - DescriptionTemplate string `yaml:"description_template,omitempty"` - Priorities *Priorities `yaml:"priorities,omitempty"` - Assignee *Assignee `yaml:"assignee,omitempty"` + Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"` + Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` + ProjectKey string `json:"projectKey,omitempty" yaml:"project_key,omitempty"` + IssueType string `json:"issueType,omitempty" yaml:"issue_type,omitempty"` + SeverityThreshold string `json:"severityThreshold,omitempty" yaml:"severity_threshold,omitempty"` + PriorityThreshold string `json:"priorityThreshold,omitempty" yaml:"priority_threshold,omitempty"` + OnFixTransition string `json:"onFixTransition,omitempty" yaml:"on_fix_transition,omitempty"` + CommentOnClose *bool `json:"commentOnClose,omitempty" yaml:"comment_on_close,omitempty"` + Labels []string `json:"labels,omitempty" yaml:"labels,omitempty"` + TitleTemplate string `json:"titleTemplate,omitempty" yaml:"title_template,omitempty"` + DescriptionTemplate string `json:"descriptionTemplate,omitempty" yaml:"description_template,omitempty"` + Priorities *Priorities `json:"priorities,omitempty" yaml:"priorities,omitempty"` + Assignee *Assignee `json:"assignee,omitempty" yaml:"assignee,omitempty"` } // Mapping of Nullify Finding severities to Jira Priorities. // The user can specify the priority of the issue based on the severity. type Priorities struct { - Critical string `yaml:"critical,omitempty"` - High string `yaml:"high,omitempty"` - Medium string `yaml:"medium,omitempty"` - Low string `yaml:"low,omitempty"` - Urgent string `yaml:"urgent,omitempty"` - Important string `yaml:"important,omitempty"` - Negligible string `yaml:"negligible,omitempty"` + Critical string `json:"critical,omitempty" yaml:"critical,omitempty"` + High string `json:"high,omitempty" yaml:"high,omitempty"` + Medium string `json:"medium,omitempty" yaml:"medium,omitempty"` + Low string `json:"low,omitempty" yaml:"low,omitempty"` + Urgent string `json:"urgent,omitempty" yaml:"urgent,omitempty"` + Important string `json:"important,omitempty" yaml:"important,omitempty"` + Negligible string `json:"negligible,omitempty" yaml:"negligible,omitempty"` } type Assignee struct { - Name string `yaml:"name,omitempty"` - ID string `yaml:"id,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + ID string `json:"id,omitempty" yaml:"id,omitempty"` } diff --git a/pkg/models/models.go b/pkg/models/models.go index df3c0ed..8ab5ef4 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -2,25 +2,25 @@ package models type Configuration struct { // git platform options - EnableFailBuilds *bool `yaml:"enable_fail_builds,omitempty"` - EnablePullRequestReviews *bool `yaml:"enable_pull_request_reviews,omitempty"` - EnableIssueDashboards *bool `yaml:"enable_issue_dashboards,omitempty"` + EnableFailBuilds *bool `json:"enableFailBuilds,omitempty" yaml:"enable_fail_builds,omitempty"` + EnablePullRequestReviews *bool `json:"enablePullRequestReviews,omitempty" yaml:"enable_pull_request_reviews,omitempty"` + EnableIssueDashboards *bool `json:"enableIssueDashboards,omitempty" yaml:"enable_issue_dashboards,omitempty"` - SeverityThreshold string `yaml:"severity_threshold,omitempty"` - PriorityThreshold string `yaml:"priority_threshold,omitempty"` + SeverityThreshold string `json:"severityThreshold,omitempty" yaml:"severity_threshold,omitempty"` + PriorityThreshold string `json:"priorityThreshold,omitempty" yaml:"priority_threshold,omitempty"` - IgnoreDirs []string `yaml:"ignore_dirs,omitempty"` - IgnorePaths []string `yaml:"ignore_paths,omitempty"` + IgnoreDirs []string `json:"ignoreDirs,omitempty" yaml:"ignore_dirs,omitempty"` + IgnorePaths []string `json:"ignorePaths,omitempty" yaml:"ignore_paths,omitempty"` - Integrations Integrations `yaml:"integrations,omitempty"` + Integrations Integrations `json:"integrations,omitempty" yaml:"integrations,omitempty"` // features - Code Code `yaml:"code"` - Dependencies Dependencies `yaml:"dependencies"` - Secrets Secrets `yaml:"secrets"` + Code Code `json:"code" yaml:"code"` + Dependencies Dependencies `json:"dependencies" yaml:"dependencies"` + Secrets Secrets `json:"secrets" yaml:"secrets"` // TODO deprecate - SecretsWhitelist []string `yaml:"secrets_whitelist,omitempty"` + SecretsWhitelist []string `json:"secretsWhitelist,omitempty" yaml:"secrets_whitelist,omitempty"` } func (c *Configuration) GetEnableFailBuilds() bool { diff --git a/pkg/models/secrets.go b/pkg/models/secrets.go index a9e0c5d..96f313e 100644 --- a/pkg/models/secrets.go +++ b/pkg/models/secrets.go @@ -1,33 +1,33 @@ package models type Secrets struct { - EnableFailBuilds *bool `yaml:"enable_fail_builds,omitempty"` - Ignore []SecretsIgnore `yaml:"ignore,omitempty"` - CustomPatterns map[string]SecretsCustomPattern `yaml:"custom_patterns,omitempty"` - CustomPatternsOverrideGlobal bool `yaml:"custom_patterns_override_global,omitempty"` + EnableFailBuilds *bool `json:"enableFailBuilds,omitempty" yaml:"enable_fail_builds,omitempty"` + Ignore []SecretsIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` + CustomPatterns map[string]SecretsCustomPattern `json:"customPatterns,omitempty" yaml:"custom_patterns,omitempty"` + CustomPatternsOverrideGlobal bool `json:"customPatternsOverrideGlobal,omitempty" yaml:"custom_patterns_override_global,omitempty"` } type SecretsIgnore struct { - Reason string `yaml:"reason,omitempty"` - Expiry string `yaml:"expiry,omitempty"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` + Expiry string `json:"expiry,omitempty" yaml:"expiry,omitempty"` // matchers - Value string `yaml:"value,omitempty"` - Pattern string `yaml:"pattern,omitempty"` - SHA256 string `yaml:"sha256,omitempty"` + Value string `json:"value,omitempty" yaml:"value,omitempty"` + Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` + SHA256 string `json:"sha256,omitempty" yaml:"sha256,omitempty"` // global config only - Repositories []string `yaml:"repositories,omitempty"` + Repositories []string `json:"repositories,omitempty" yaml:"repositories,omitempty"` // TODO deprecate - Paths []string `yaml:"paths,omitempty"` + Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"` } type SecretsCustomPattern struct { - Description *string `yaml:"description,omitempty"` - SecretRegex string `yaml:"secret_regex,omitempty"` - SecretRegexGroup *int `yaml:"secret_regex_group,omitempty"` - Entropy *float32 `yaml:"entropy,omitempty"` - PathRegex *string `yaml:"path_regex,omitempty"` - Keywords []string `yaml:"keywords,omitempty"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + SecretRegex string `json:"secretRegex,omitempty" yaml:"secret_regex,omitempty"` + SecretRegexGroup *int `json:"secretRegexGroup,omitempty" yaml:"secret_regex_group,omitempty"` + Entropy *float32 `json:"entropy,omitempty" yaml:"entropy,omitempty"` + PathRegex *string `json:"pathRegex,omitempty" yaml:"path_regex,omitempty"` + Keywords []string `json:"keywords,omitempty" yaml:"keywords,omitempty"` }