Skip to content

Commit

Permalink
add security phase 1
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenharrison committed Aug 30, 2024
1 parent 430d296 commit c97b1c3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
5 changes: 4 additions & 1 deletion checker/generator/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func getHierarchyMessage(hierarchy []string, atttibuted []bool) string {
}

func isTopLevel(s string) bool {
return s == "request body" || s == "paths"
return s == "request body" ||
s == "paths"
}

func standardizeSpaces(s string) string {
Expand Down Expand Up @@ -110,6 +111,8 @@ func conjugate(verb string) string {
return "set"
case "add":
return "added"
case "become":
return "became"
}
return verb + "d"
}
Expand Down
41 changes: 41 additions & 0 deletions checker/generator/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ func getAll() ValueSets {
getPaths(),
getRequest(),
getResponse(),
getComponents(),
)
}

Expand All @@ -29,13 +30,49 @@ func getPaths() ValueSets {
return NewValueSets(nil, nil, pathsValueSets)
}

func getComponents() ValueSets {
return slices.Concat(
getSecurity(),
)
}

func getSecurity() ValueSets {
return NewValueSets(nil, nil, securityValueSets)
}

var securityValueSets = ValueSets{
ValueSetB{
adjective: "%s",
adjectiveType: PREDICATIVE,
nouns: []string{"endpoint scheme security"},
actions: []string{"add", "remove"},
},
ValueSetB{
adjective: "%s",
adjectiveType: PREDICATIVE,
hierarchy: []string{"global security scheme"},
attributed: []bool{false},
nouns: []string{"security scope"},
actions: []string{"add", "remove"},
},
}

var pathsValueSets = ValueSets{
ValueSetB{
adjective: "%s",
adjectiveType: PREDICATIVE,
nouns: []string{"success response status", "non-success response status"},
actions: []string{"add", "remove"},
},
ValueSetB{
adjective: "%s",
adjectiveType: PREDICATIVE,
hierarchy: []string{"endpoint security scheme"},
attributed: []bool{false},
nouns: []string{"security scope"},
actions: []string{"add", "remove"},
},
// security scope %s was added to endpoint security scheme %s
}

var schemaValueSets = ValueSets{
Expand All @@ -57,6 +94,10 @@ var schemaValueSets = ValueSets{
nouns: []string{"pattern"},
actions: []string{"change"},
},
ValueSetA{
nouns: []string{"required property", "optional property"},
actions: []string{"change"},
},
ValueSetB{
adjective: "%s",
adjectiveType: PREDICATIVE,
Expand Down
16 changes: 16 additions & 0 deletions checker/generator/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ success-response-status-added: added success response status %s
success-response-status-removed: removed success response status %s
non-success-response-status-added: added non-success response status %s
non-success-response-status-removed: removed non-success response status %s
endpoint-security-scheme-security-scope-added: added security scope %s to endpoint security scheme %s
endpoint-security-scheme-security-scope-removed: removed security scope %s from endpoint security scheme %s
request-body-media-type-max-set: max value of media-type %s of request body was set to %s
request-body-media-type-max-increased: max value of media-type %s of request body was increased from %s to %s
request-body-media-type-max-decreased: max value of media-type %s of request body was decreased from %s to %s
Expand All @@ -24,6 +26,8 @@ request-body-media-type-type-changed: type/format of media-type %s of request bo
request-body-media-type-type-generalized: type/format of media-type %s of request body was generalized from %s to %s
request-body-media-type-discriminator-property-name-changed: discriminator property name of media-type %s of request body was changed from %s to %s
request-body-media-type-pattern-changed: pattern of media-type %s of request body was changed from %s to %s
request-body-media-type-required-property-changed: required property of media-type %s of request body was changed from %s to %s
request-body-media-type-optional-property-changed: optional property of media-type %s of request body was changed from %s to %s
request-body-media-type-pattern-added: added pattern %s to media-type %s of request body
request-body-media-type-pattern-removed: removed pattern %s from media-type %s of request body
request-body-media-type-default-value-added: added default value to media-type %s of request body
Expand Down Expand Up @@ -60,6 +64,8 @@ request-body-media-type-property-type-changed: type/format of property %s of med
request-body-media-type-property-type-generalized: type/format of property %s of media-type %s of request body was generalized from %s to %s
request-body-media-type-property-discriminator-property-name-changed: discriminator property name of property %s of media-type %s of request body was changed from %s to %s
request-body-media-type-property-pattern-changed: pattern of property %s of media-type %s of request body was changed from %s to %s
request-body-media-type-property-required-property-changed: required property of property %s of media-type %s of request body was changed from %s to %s
request-body-media-type-property-optional-property-changed: optional property of property %s of media-type %s of request body was changed from %s to %s
request-body-media-type-property-pattern-added: added pattern %s to property %s of media-type %s of request body
request-body-media-type-property-pattern-removed: removed pattern %s from property %s of media-type %s of request body
request-body-media-type-property-default-value-added: added default value to property %s of media-type %s of request body
Expand Down Expand Up @@ -96,6 +102,8 @@ request-parameter-type-changed: type/format of %s request parameter %s was chang
request-parameter-type-generalized: type/format of %s request parameter %s was generalized from %s to %s
request-parameter-discriminator-property-name-changed: discriminator property name of %s request parameter %s was changed from %s to %s
request-parameter-pattern-changed: pattern of %s request parameter %s was changed from %s to %s
request-parameter-required-property-changed: required property of %s request parameter %s was changed from %s to %s
request-parameter-optional-property-changed: optional property of %s request parameter %s was changed from %s to %s
request-parameter-pattern-added: added pattern %s to %s request parameter %s
request-parameter-pattern-removed: removed pattern %s from %s request parameter %s
request-parameter-default-value-added: added default value to %s request parameter %s
Expand Down Expand Up @@ -132,6 +140,8 @@ response-media-type-type-changed: type/format of media-type %s of response %s wa
response-media-type-type-generalized: type/format of media-type %s of response %s was generalized from %s to %s
response-media-type-discriminator-property-name-changed: discriminator property name of media-type %s of response %s was changed from %s to %s
response-media-type-pattern-changed: pattern of media-type %s of response %s was changed from %s to %s
response-media-type-required-property-changed: required property of media-type %s of response %s was changed from %s to %s
response-media-type-optional-property-changed: optional property of media-type %s of response %s was changed from %s to %s
response-media-type-pattern-added: added pattern %s to media-type %s of response %s
response-media-type-pattern-removed: removed pattern %s from media-type %s of response %s
response-media-type-default-value-added: added default value to media-type %s of response %s
Expand Down Expand Up @@ -168,6 +178,8 @@ response-media-type-property-type-changed: type/format of property %s of media-t
response-media-type-property-type-generalized: type/format of property %s of media-type %s of response %s was generalized from %s to %s
response-media-type-property-discriminator-property-name-changed: discriminator property name of property %s of media-type %s of response %s was changed from %s to %s
response-media-type-property-pattern-changed: pattern of property %s of media-type %s of response %s was changed from %s to %s
response-media-type-property-required-property-changed: required property of property %s of media-type %s of response %s was changed from %s to %s
response-media-type-property-optional-property-changed: optional property of property %s of media-type %s of response %s was changed from %s to %s
response-media-type-property-pattern-added: added pattern %s to property %s of media-type %s of response %s
response-media-type-property-pattern-removed: removed pattern %s from property %s of media-type %s of response %s
response-media-type-property-default-value-added: added default value to property %s of media-type %s of response %s
Expand All @@ -182,3 +194,7 @@ response-media-type-property-discriminator-added: added discriminator %s to prop
response-media-type-property-discriminator-removed: removed discriminator %s from property %s of media-type %s of response %s
response-media-type-property-mapping-keys-added: added mapping keys %s to property %s of media-type %s of response %s
response-media-type-property-mapping-keys-removed: removed mapping keys %s from property %s of media-type %s of response %s
endpoint-scheme-security-added: added endpoint scheme security %s
endpoint-scheme-security-removed: removed endpoint scheme security %s
global-security-scheme-security-scope-added: added security scope %s to global security scheme %s
global-security-scheme-security-scope-removed: removed security scope %s from global security scheme %s

0 comments on commit c97b1c3

Please sign in to comment.