Remove superseded history attribution paths
This commit is contained in:
@@ -11,11 +11,11 @@ type secretDependency struct {
|
||||
dependency Path
|
||||
}
|
||||
|
||||
func classifySecretPaths(schema *schemaDescriptor, predicate func(Path) bool, metadata Metadata, final *document.Node, applications []historyApplication, projections ...*document.Node) map[string]bool {
|
||||
return classifySecretPathsWithEvidence(schema, predicate, metadata, final, applications, nil, projections...)
|
||||
func classifySecretPaths(schema *schemaDescriptor, predicate func(Path) bool, metadata Metadata) map[string]bool {
|
||||
return classifySecretPathsWithEvidence(schema, predicate, metadata, nil)
|
||||
}
|
||||
|
||||
func classifySecretPathsWithEvidence(schema *schemaDescriptor, predicate func(Path) bool, metadata Metadata, final *document.Node, applications []historyApplication, evidence []*sourceVersionEvidence, projections ...*document.Node) map[string]bool {
|
||||
func classifySecretPathsWithEvidence(schema *schemaDescriptor, predicate func(Path) bool, metadata Metadata, evidence []*sourceVersionEvidence) map[string]bool {
|
||||
paths := make(map[string]Path)
|
||||
candidateShapes := make(map[string][]Path)
|
||||
var candidates []Path
|
||||
@@ -30,19 +30,9 @@ func classifySecretPathsWithEvidence(schema *schemaDescriptor, predicate func(Pa
|
||||
candidateShapes[pointer] = append(candidateShapes[pointer], cloned)
|
||||
candidates = append(candidates, cloned)
|
||||
}
|
||||
for _, application := range applications {
|
||||
walkHistoryApplication(application, func(_ Path, path Path, _ *document.Node) {
|
||||
if len(application.sequences) != 0 {
|
||||
addCandidate(path)
|
||||
} else if parsed, err := ParsePath(path.String()); err == nil {
|
||||
addCandidate(parsed)
|
||||
}
|
||||
addSecretPath(paths, path.String())
|
||||
})
|
||||
}
|
||||
secret := make(map[string]bool)
|
||||
var dependencies, inherited []secretDependency
|
||||
if model := metadata.currentHistoryModel(); model != nil {
|
||||
if model := metadata.historyEvidence(); model != nil {
|
||||
dependencies, inherited = model.sensitivityDependencies()
|
||||
for _, candidate := range model.sensitivityCandidates() {
|
||||
pointer := candidate.path.String()
|
||||
@@ -71,22 +61,6 @@ func classifySecretPathsWithEvidence(schema *schemaDescriptor, predicate func(Pa
|
||||
}
|
||||
}
|
||||
|
||||
classifyProjection := func(tree *document.Node) {
|
||||
walkDocument(tree, Path{}, func(path Path, node *document.Node) {
|
||||
pointer := path.String()
|
||||
addSecretPath(paths, pointer)
|
||||
if parsed, err := ParsePath(pointer); err == nil {
|
||||
addCandidate(parsed)
|
||||
}
|
||||
if node.Sensitive {
|
||||
secret[pointer] = true
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, tree := range projections {
|
||||
classifyProjection(tree)
|
||||
}
|
||||
classifyProjection(final)
|
||||
classifyPath := func(path Path) {
|
||||
if root, ok := schemaSecretRoot(schema, path); ok {
|
||||
secret[root.String()] = true
|
||||
|
||||
Reference in New Issue
Block a user