mirror of https://github.com/daffainfo/nuclei.git
Merge pull request #1032 from projectdiscovery/metadata-update
Replaced the "additional-fields" attribute with "metadata" for conveniencedev
commit
261279d4c2
|
@ -415,12 +415,12 @@ Valid values:
|
||||||
|
|
||||||
<div class="dd">
|
<div class="dd">
|
||||||
|
|
||||||
<code>additional-fields</code> <i>map[string]string</i>
|
<code>metadata</code> <i>map[string]string</i>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="dt">
|
<div class="dt">
|
||||||
|
|
||||||
AdditionalFields regarding metadata of the template.
|
Metadata regarding metadata of the template.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ Examples:
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
additional-fields:
|
metadata:
|
||||||
customField1: customValue1
|
customField1: customValue1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"$ref": "#/definitions/severity.Holder"
|
"$ref": "#/definitions/severity.Holder"
|
||||||
},
|
},
|
||||||
"additional-fields": {
|
"metadata": {
|
||||||
"patternProperties": {
|
"patternProperties": {
|
||||||
".*": {
|
".*": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
|
@ -114,7 +114,6 @@ func getCVEData(client *nvd.Client, filePath, data string) {
|
||||||
newInfoBlock = strings.ReplaceAll(newInfoBlock, severityMatches[0][0], "severity: "+newSeverity)
|
newInfoBlock = strings.ReplaceAll(newInfoBlock, severityMatches[0][0], "severity: "+newSeverity)
|
||||||
fmt.Printf("Adjusting severity for %s from %s=>%s (%.2f)\n", filePath, severityValue, newSeverity, cvssScore)
|
fmt.Printf("Adjusting severity for %s from %s=>%s (%.2f)\n", filePath, severityValue, newSeverity, cvssScore)
|
||||||
}
|
}
|
||||||
// Start with additional-fields as that is the one most likely to break stuff.
|
|
||||||
if !strings.Contains(infoBlockClean, "classification") && (cvssScore != 0 && cvssMetrics != "") {
|
if !strings.Contains(infoBlockClean, "classification") && (cvssScore != 0 && cvssMetrics != "") {
|
||||||
changed = true
|
changed = true
|
||||||
newInfoBlock = newInfoBlock + fmt.Sprintf("\n classification:\n cvss-metrics: %s\n cvss-score: %.2f\n cve-id: %s", cvssMetrics, cvssScore, cveName)
|
newInfoBlock = newInfoBlock + fmt.Sprintf("\n classification:\n cvss-metrics: %s\n cvss-score: %.2f\n cve-id: %s", cvssMetrics, cvssScore, cveName)
|
||||||
|
|
|
@ -59,12 +59,12 @@ type Info struct {
|
||||||
// - critical
|
// - critical
|
||||||
SeverityHolder severity.Holder `json:"severity,omitempty" yaml:"severity,omitempty"`
|
SeverityHolder severity.Holder `json:"severity,omitempty" yaml:"severity,omitempty"`
|
||||||
// description: |
|
// description: |
|
||||||
// AdditionalFields regarding metadata of the template.
|
// Metadata of the template.
|
||||||
//
|
//
|
||||||
// examples:
|
// examples:
|
||||||
// - value: >
|
// - value: >
|
||||||
// map[string]string{"customField1":"customValue1"}
|
// map[string]string{"customField1":"customValue1"}
|
||||||
AdditionalFields map[string]string `json:"additional-fields,omitempty" yaml:"additional-fields,omitempty" jsonschema:"title=additional metadata for the template,description=Additional metadata fields for the template"`
|
Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty" jsonschema:"title=additional metadata for the template,description=Additional metadata fields for the template"`
|
||||||
|
|
||||||
// description: |
|
// description: |
|
||||||
// Classification contains classification information about the template.
|
// Classification contains classification information about the template.
|
||||||
|
|
|
@ -80,7 +80,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
assert.Equal(t, info.Tags.ToSlice(), tags)
|
assert.Equal(t, info.Tags.ToSlice(), tags)
|
||||||
assert.Equal(t, info.SeverityHolder.Severity, severity.Critical)
|
assert.Equal(t, info.SeverityHolder.Severity, severity.Critical)
|
||||||
assert.Equal(t, info.Reference.ToSlice(), references)
|
assert.Equal(t, info.Reference.ToSlice(), references)
|
||||||
assert.Equal(t, info.AdditionalFields, dynamicKeysMap)
|
assert.Equal(t, info.Metadata, dynamicKeysMap)
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
tags: ` + strings.Join(tags, ", ") + `
|
tags: ` + strings.Join(tags, ", ") + `
|
||||||
severity: critical
|
severity: critical
|
||||||
reference: ` + strings.Join(references, ", ") + `
|
reference: ` + strings.Join(references, ", ") + `
|
||||||
additional-fields:
|
metadata:
|
||||||
` + dynamicKey1 + `: ` + dynamicKeysMap[dynamicKey1] + `
|
` + dynamicKey1 + `: ` + dynamicKeysMap[dynamicKey1] + `
|
||||||
` + dynamicKey2 + `: ` + dynamicKeysMap[dynamicKey2] + `
|
` + dynamicKey2 + `: ` + dynamicKeysMap[dynamicKey2] + `
|
||||||
`
|
`
|
||||||
|
@ -106,7 +106,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
reference:
|
reference:
|
||||||
- ` + references[0] + ` # comments are not unmarshalled
|
- ` + references[0] + ` # comments are not unmarshalled
|
||||||
- ` + references[1] + `
|
- ` + references[1] + `
|
||||||
additional-fields:
|
metadata:
|
||||||
` + dynamicKey1 + `: ` + dynamicKeysMap[dynamicKey1] + `
|
` + dynamicKey1 + `: ` + dynamicKeysMap[dynamicKey1] + `
|
||||||
` + dynamicKey2 + `: ` + dynamicKeysMap[dynamicKey2] + `
|
` + dynamicKey2 + `: ` + dynamicKeysMap[dynamicKey2] + `
|
||||||
`
|
`
|
||||||
|
|
|
@ -182,7 +182,7 @@ func ToMarkdownTableString(templateInfo *model.Info) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMarkDownTable(fields)
|
toMarkDownTable(fields)
|
||||||
toMarkDownTable(utils.NewInsertionOrderedStringMap(templateInfo.AdditionalFields))
|
toMarkDownTable(utils.NewInsertionOrderedStringMap(templateInfo.Metadata))
|
||||||
|
|
||||||
return builder.String()
|
return builder.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestToMarkdownTableString(t *testing.T) {
|
||||||
SeverityHolder: severity.Holder{Severity: severity.High},
|
SeverityHolder: severity.Holder{Severity: severity.High},
|
||||||
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
|
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
|
||||||
Reference: stringslice.StringSlice{Value: "reference1"},
|
Reference: stringslice.StringSlice{Value: "reference1"},
|
||||||
AdditionalFields: map[string]string{
|
Metadata: map[string]string{
|
||||||
"customDynamicKey1": "customDynamicValue1",
|
"customDynamicKey1": "customDynamicValue1",
|
||||||
"customDynamicKey2": "customDynamicValue2",
|
"customDynamicKey2": "customDynamicValue2",
|
||||||
},
|
},
|
||||||
|
|
|
@ -148,11 +148,11 @@ func init() {
|
||||||
"high",
|
"high",
|
||||||
"critical",
|
"critical",
|
||||||
}
|
}
|
||||||
MODELInfoDoc.Fields[6].Name = "additional-fields"
|
MODELInfoDoc.Fields[6].Name = "metadata"
|
||||||
MODELInfoDoc.Fields[6].Type = "map[string]string"
|
MODELInfoDoc.Fields[6].Type = "map[string]string"
|
||||||
MODELInfoDoc.Fields[6].Note = ""
|
MODELInfoDoc.Fields[6].Note = ""
|
||||||
MODELInfoDoc.Fields[6].Description = "AdditionalFields regarding metadata of the template."
|
MODELInfoDoc.Fields[6].Description = "Metadata of the template."
|
||||||
MODELInfoDoc.Fields[6].Comments[encoder.LineComment] = "AdditionalFields regarding metadata of the template."
|
MODELInfoDoc.Fields[6].Comments[encoder.LineComment] = "Metadata of the template."
|
||||||
|
|
||||||
MODELInfoDoc.Fields[6].AddExample("", map[string]string{"customField1": "customValue1"})
|
MODELInfoDoc.Fields[6].AddExample("", map[string]string{"customField1": "customValue1"})
|
||||||
MODELInfoDoc.Fields[7].Name = "classification"
|
MODELInfoDoc.Fields[7].Name = "classification"
|
||||||
|
|
Loading…
Reference in New Issue