Skip to content

Commit

Permalink
chore: include yaml option to struct (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Nov 22, 2022
1 parent 644b7ff commit 67e0bd9
Show file tree
Hide file tree
Showing 45 changed files with 251 additions and 251 deletions.
8 changes: 4 additions & 4 deletions battle_tests/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
var githubDir embed.FS

type Category struct {
Language string `json:"Language"`
Items []Item `json:"items"`
Language string `json:"language" yaml:"language"`
Items []Item `json:"items" yaml:"items"`
}

type Item struct {
FullName string `json:"full_name"`
HtmlUrl string `json:"html_url"`
FullName string `json:"full_name" yaml:"full_name"`
HtmlUrl string `json:"html_url" yaml:"html_url"`
}

func UnmarshalRaw() []Item {
Expand Down
10 changes: 5 additions & 5 deletions battle_tests/metrics_scan/metrics_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
)

type DataType struct {
Name string `json:"name"`
Occurrences float64 `json:"occurrences"`
Name string `json:"name" yaml:"name"`
Occurrences float64 `json:"occurrences" yaml:"occurrences"`
}

type ScanReport struct {
NumberOfLines int `json:"number_of_lines"`
NumberOfDataTypes int `json:"number_of_data_types"`
DataTypes []DataType `json:"data_types"`
NumberOfLines int `json:"number_of_lines" yaml:"number_of_lines"`
NumberOfDataTypes int `json:"number_of_data_types" yaml:"number_of_data_types"`
DataTypes []DataType `json:"data_types" yaml:"data_types"`
}

type MetricsReport struct {
Expand Down
70 changes: 35 additions & 35 deletions pkg/classification/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ type DefaultDB struct {
}

type Recipe struct {
URLS []string `json:"urls"`
Name string `json:"name"`
Type string `json:"type"`
Packages []Package `json:"packages"`
UUID string `json:"uuid"`
URLS []string `json:"urls" yaml:"urls"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Packages []Package `json:"packages" yaml:"packages"`
UUID string `json:"uuid" yaml:"uuid"`
}

type Package struct {
Name string `json:"name"`
PackageManager string `json:"package_manager"`
Group string `json:"group"`
Name string `json:"name" yaml:"name"`
PackageManager string `json:"package_manager" yaml:"package_manager"`
Group string `json:"group" yaml:"group"`
}

type RecipeType string
Expand All @@ -53,15 +53,15 @@ var RecipeTypeDataStore = RecipeType("data_store")
var RecipeTypeService = RecipeType("service")

type DataType struct {
Name string `json:"name"`
UUID string `json:"uuid"`
CategoryUUID string `json:"category_uuid"`
Name string `json:"name" yaml:"name"`
UUID string `json:"uuid" yaml:"uuid"`
CategoryUUID string `json:"category_uuid" yaml:"category_uuid"`
}

type DataCategory struct {
Name string `json:"name"`
UUID string `json:"uuid"`
Severity string `json:"severity"`
Name string `json:"name" yaml:"name"`
UUID string `json:"uuid" yaml:"uuid"`
Severity string `json:"severity" yaml:"severity"`
}

type ObjectType string
Expand All @@ -73,34 +73,34 @@ var AssociatedObject ObjectType = "associated"
var KnownDataObject ObjectType = "known_data_object"

type DataTypeClassificationPattern struct {
Id int `json:"id"`
Id int `json:"id" yaml:"id"`
DataTypeUUID string `json:"data_type_uuid,omitempty"`
DataType DataType `json:"data_type"`
IncludeRegexp string `json:"include_regexp"`
IncludeRegexpMatcher *regexp.Regexp `json:"include_regexp_matcher"`
DataType DataType `json:"data_type" yaml:"data_type"`
IncludeRegexp string `json:"include_regexp" yaml:"include_regexp"`
IncludeRegexpMatcher *regexp.Regexp `json:"include_regexp_matcher" yaml:"include_regexp_matcher"`
ExcludeRegexp string `json:"exclude_regexp,omitempty"`
ExcludeRegexpMatcher *regexp.Regexp `json:"exclude_regexp_matcher"`
ExcludeTypes []string `json:"exclude_types"`
ExcludeTypesMapping map[string]struct{} `json:"exclude_types_mapping"`
FriendlyName string `json:"friendly_name"`
ExcludeRegexpMatcher *regexp.Regexp `json:"exclude_regexp_matcher" yaml:"exclude_regexp_matcher"`
ExcludeTypes []string `json:"exclude_types" yaml:"exclude_types"`
ExcludeTypesMapping map[string]struct{} `json:"exclude_types_mapping" yaml:"exclude_types_mapping"`
FriendlyName string `json:"friendly_name" yaml:"friendly_name"`
HealthContextDataTypeUUID string `json:"health_context_data_type_uuid,omitempty"`
HealthContextDataType DataType `json:"health_context_data_type"`
MatchColumn bool `json:"match_column"`
MatchObject bool `json:"match_object"`
ObjectType []string `json:"object_type"`
ObjectTypeMapping map[string]struct{} `json:"object_types_mapping"`
HealthContextDataType DataType `json:"health_context_data_type" yaml:"health_context_data_type"`
MatchColumn bool `json:"match_column" yaml:"match_column"`
MatchObject bool `json:"match_object" yaml:"match_object"`
ObjectType []string `json:"object_type" yaml:"object_type"`
ObjectTypeMapping map[string]struct{} `json:"object_types_mapping" yaml:"object_types_mapping"`
}

type KnownPersonObjectPattern struct {
Id int `json:"id"`
DataType DataType `json:"data_type"`
IncludeRegexp string `json:"include_regexp"`
IncludeRegexpMatcher *regexp.Regexp `json:"include_regexp_matcher"`
Id int `json:"id" yaml:"id"`
DataType DataType `json:"data_type" yaml:"data_type"`
IncludeRegexp string `json:"include_regexp" yaml:"include_regexp"`
IncludeRegexpMatcher *regexp.Regexp `json:"include_regexp_matcher" yaml:"include_regexp_matcher"`
ExcludeRegexp string `json:"exclude_regexp,omitempty"`
ExcludeRegexpMatcher *regexp.Regexp `json:"exclude_regexp_matcher"`
Category string `json:"category"`
ActAsIdentifier bool `json:"act_as_identifier"`
IdentifierRegexpMatcher *regexp.Regexp `json:"identifier_regexp_matcher"`
ExcludeRegexpMatcher *regexp.Regexp `json:"exclude_regexp_matcher" yaml:"exclude_regexp_matcher"`
Category string `json:"category" yaml:"category"`
ActAsIdentifier bool `json:"act_as_identifier" yaml:"act_as_identifier"`
IdentifierRegexpMatcher *regexp.Regexp `json:"identifier_regexp_matcher" yaml:"identifier_regexp_matcher"`
}

func Default() DefaultDB {
Expand Down
6 changes: 3 additions & 3 deletions pkg/classification/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (

type ClassifiedDependency struct {
*detections.Detection
Classification *Classification `json:"classification"`
Classification *Classification `json:"classification" yaml:"classification"`
}

type Classification struct {
RecipeMatch bool `json:"recipe_match"`
RecipeMatch bool `json:"recipe_match" yaml:"recipe_match"`
RecipeUUID string `json:"recipe_uuid,omitempty"`
RecipeName string `json:"recipe_name,omitempty"`
Decision classify.ClassificationDecision `json:"decision"`
Decision classify.ClassificationDecision `json:"decision" yaml:"decision"`
}

type Classifier struct {
Expand Down
10 changes: 5 additions & 5 deletions pkg/classification/frameworks/frameworks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (

type ClassifiedFramework struct {
*detections.Detection
Classification *Classification `json:"classification"`
Classification *Classification `json:"classification" yaml:"classification"`
}

type Classification struct {
RecipeMatch bool `json:"recipe_match"`
RecipeName string `json:"recipe_name,omitempty"`
RecipeUUID string `json:"recipe_uuid,omitempty"`
Decision classify.ClassificationDecision `json:"decision"`
RecipeMatch bool `json:"recipe_match" yaml:"recipe_match"`
RecipeName string `json:"recipe_name,omitempty"`
RecipeUUID string `json:"recipe_uuid,omitempty"`
Decision classify.ClassificationDecision `json:"decision" yaml:"decision"`
}

type Classifier struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/classification/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (

type ClassifiedInterface struct {
*detections.Detection
Classification *Classification `json:"classification"`
Classification *Classification `json:"classification" yaml:"classification"`
}

type Classification struct {
URL string `json:"url"`
RecipeMatch bool `json:"recipe_match"`
URL string `json:"url" yaml:"url"`
RecipeMatch bool `json:"recipe_match" yaml:"recipe_match"`
RecipeName string `json:"recipe_name,omitempty"`
RecipeUUID string `json:"recipe_uuid,omitempty"`
Decision classify.ClassificationDecision `json:"decision"`
Decision classify.ClassificationDecision `json:"decision" yaml:"decision"`
}

type Classifier struct {
Expand Down
24 changes: 12 additions & 12 deletions pkg/classification/schema/internal/testhelper/testhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ type Output struct {
}

type InputProperties struct {
Name string `json:"name"`
Type string `json:"type"`
State string `json:"state"`
Reason string `json:"reason"`
FalsePositive bool `json:"false_positive"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
State string `json:"state" yaml:"state"`
Reason string `json:"reason" yaml:"reason"`
FalsePositive bool `json:"false_positive" yaml:"false_positive"`
}

type Input struct {
Name string `json:"name"`
Filename string `json:"filename"`
DetectorType string `json:"detector_type"`
Properties []InputProperties `json:"properties"`
State string `json:"state"`
Reason string `json:"reason"`
FalsePositive bool `json:"false_positive"`
Name string `json:"name" yaml:"name"`
Filename string `json:"filename" yaml:"filename"`
DetectorType string `json:"detector_type" yaml:"detector_type"`
Properties []InputProperties `json:"properties" yaml:"properties"`
State string `json:"state" yaml:"state"`
Reason string `json:"reason" yaml:"reason"`
FalsePositive bool `json:"false_positive" yaml:"false_positive"`
}

func ExtractExpectedOutput(
Expand Down
6 changes: 3 additions & 3 deletions pkg/classification/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ var regexpTimestampsMatcher = regexp.MustCompile(`\A(created|updated)\sat\z`)

type ClassifiedDatatype struct {
datatype.DataTypable
Classification Classification `json:"classification"`
Classification Classification `json:"classification" yaml:"classification"`
}

func (datatype ClassifiedDatatype) GetClassification() interface{} {
return datatype.Classification
}

type Classification struct {
Name string `json:"name"`
Name string `json:"name" yaml:"name"`
DataType *db.DataType `json:"data_type,omitempty"`
Decision classify.ClassificationDecision `json:"decision"`
Decision classify.ClassificationDecision `json:"decision" yaml:"decision"`
}

type Classifier struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// VersionInfo holds the curio version
type VersionInfo struct {
Version string `json:",omitempty"`
Version string `json:",omitempty" yaml:",omitempty"`
}

// NewApp is the factory method to return Curio CLI
Expand Down
8 changes: 4 additions & 4 deletions pkg/commands/process/repo_info/repo_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
)

type renamedFileReport struct {
Type string `json:"type"`
Files []git.RenamedFile `json:"files"`
Type string `json:"type" yaml:"type"`
Files []git.RenamedFile `json:"files" yaml:"files"`
}

type commitInfoReport struct {
Type string `json:"type"`
Commits []git.CommitInfo `json:"commits"`
Type string `json:"type" yaml:"type"`
Commits []git.CommitInfo `json:"commits" yaml:"commits"`
}

func ReportRepositoryInfo(reportWriter io.Writer, repository work.Repository, commitList []git.CommitInfo) error {
Expand Down
10 changes: 5 additions & 5 deletions pkg/commands/process/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

type Config struct {
Worker flag.WorkerOptions `json:"worker"`
Scan flag.ScanOptions `json:"scan"`
Report flag.ReportOptions `json:"report"`
CustomDetector map[string]Rule `json:"custom_detector"`
Policies map[string]*Policy `json:"policies"`
Worker flag.WorkerOptions `json:"worker" yaml:"worker"`
Scan flag.ScanOptions `json:"scan" yaml:"scan"`
Report flag.ReportOptions `json:"report" yaml:"report"`
CustomDetector map[string]Rule `json:"custom_detector" yaml:"custom_detector"`
Policies map[string]*Policy `json:"policies" yaml:"policies"`
}

type policyLevel string
Expand Down
18 changes: 9 additions & 9 deletions pkg/detectors/dependencies/depsbase/depsbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package depsbase

// Dependency is a dependency that keeps the name and version
type Dependency struct {
Group string `json:"group"`
Name string `json:"name"`
Version string `json:"version"`
Line int64 `json:"lineNumber,omitempty"`
Column int64 `json:"columnNumber,omitempty"`
Group string `json:"group" yaml:"group"`
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Line int64 `json:"lineNumber,omitempty" yaml:"lineNumber,omitempty"`
Column int64 `json:"columnNumber,omitempty" yaml:"columnNumber,omitempty"`
}

// DiscoveredDependency holds a list of dependencies defined in package file
type DiscoveredDependency struct {
Provider string `json:"provider"`
Language string `json:"language"`
PackageManager string `json:"package_manager"`
Dependencies []Dependency `json:"dependencies"`
Provider string `json:"provider" yaml:"provider"`
Language string `json:"language" yaml:"language"`
PackageManager string `json:"package_manager" yaml:"package_manager"`
Dependencies []Dependency `json:"dependencies" yaml:"dependencies"`
}
2 changes: 1 addition & 1 deletion pkg/flag/general_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type GeneralFlagGroup struct {

// GlobalOptions defines flags and other configuration parameters for all the subcommands
type GeneralOptions struct {
ConfigFile string `json:"config_file"`
ConfigFile string `json:"config_file" yaml:"config_file"`
}

func NewGeneralFlagGroup() *GeneralFlagGroup {
Expand Down
4 changes: 2 additions & 2 deletions pkg/flag/policy_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type PolicyFlagGroup struct {
}

type PolicyOptions struct {
SkipPolicy map[string]bool `json:"skip_policy"`
OnlyPolicy map[string]bool `json:"only_policy"`
SkipPolicy map[string]bool `json:"skip_policy" yaml:"skip_policy"`
OnlyPolicy map[string]bool `json:"only_policy" yaml:"only_policy"`
}

func NewPolicyFlagGroup() *PolicyFlagGroup {
Expand Down
16 changes: 8 additions & 8 deletions pkg/flag/scan_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ type ScanFlagGroup struct {
}

type ScanOptions struct {
Target string `json:"target"`
SkipPath []string `json:"skip_path"`
Debug bool `json:"debug"`
DisableDomainResolution bool `json:"disable_domain_resolution"`
DomainResolutionTimeout time.Duration `json:"domain_resolution_timeout"`
InternalDomains []string `json:"internal_domains"`
Context Context `json:"context"`
Quiet bool `json:"quiet"`
Target string `json:"target" yaml:"target"`
SkipPath []string `json:"skip_path" yaml:"skip_path"`
Debug bool `json:"debug" yaml:"debug"`
DisableDomainResolution bool `json:"disable_domain_resolution" yaml:"disable_domain_resolution"`
DomainResolutionTimeout time.Duration `json:"domain_resolution_timeout" yaml:"domain_resolution_timeout"`
InternalDomains []string `json:"internal_domains" yaml:"internal_domains"`
Context Context `json:"context" yaml:"context"`
Quiet bool `json:"quiet" yaml:"quiet"`
}

func NewScanFlagGroup() *ScanFlagGroup {
Expand Down
20 changes: 10 additions & 10 deletions pkg/flag/worker_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ type WorkerFlagGroup struct {

// GlobalOptions defines flags and other configuration parameters for all the subcommands
type WorkerOptions struct {
Workers int `json:"workers"`
Timeout time.Duration `json:"timeout"`
TimeoutFileMinimum time.Duration `json:"timeout_file_minimum"`
TimeoutFileMaximum time.Duration `json:"timeout_file_maximum"`
TimeoutFileSecondPerBytes int `json:"timeout_file_second_per_bytes"`
TimeoutWorkerOnline time.Duration `json:"timeout_worker_online"`
FileSizeMaximum int `json:"file_size_maximum"`
FilesToBatch int `json:"files_to_batch"`
MemoryMaximum int `json:"memory_maximum"`
ExistingWorker string `json:"existing_worker"`
Workers int `json:"workers" yaml:"workers"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
TimeoutFileMinimum time.Duration `json:"timeout_file_minimum" yaml:"timeout_file_minimum"`
TimeoutFileMaximum time.Duration `json:"timeout_file_maximum" yaml:"timeout_file_maximum"`
TimeoutFileSecondPerBytes int `json:"timeout_file_second_per_bytes" yaml:"timeout_file_second_per_bytes"`
TimeoutWorkerOnline time.Duration `json:"timeout_worker_online" yaml:"timeout_worker_online"`
FileSizeMaximum int `json:"file_size_maximum" yaml:"file_size_maximum"`
FilesToBatch int `json:"files_to_batch" yaml:"files_to_batch"`
MemoryMaximum int `json:"memory_maximum" yaml:"memory_maximum"`
ExistingWorker string `json:"existing_worker" yaml:"existing_worker"`
}

func NewWorkerFlagGroup() *WorkerFlagGroup {
Expand Down
Loading

0 comments on commit 67e0bd9

Please sign in to comment.