Project version protections through item placement
This commit is contained in:
@@ -91,11 +91,15 @@ func sourceVersionCheckForEvidence(evidence *sourceVersionEvidence, sensitivity
|
||||
}
|
||||
}
|
||||
|
||||
func (state *sourceVersionState) process(root *document.Node, role sourceVersionRole, destination Path, sourceID string) (sourceVersionProcessingResult, []Diagnostic) {
|
||||
func (state *sourceVersionState) process(root *document.Node, role sourceVersionRole, destination Path, sourceID string, placement placementMode) (sourceVersionProcessingResult, []Diagnostic) {
|
||||
if state == nil || state.mode == sourceVersionModeDefault {
|
||||
return sourceVersionProcessingResult{}, nil
|
||||
}
|
||||
result := processSourceVersion(root, state.localRule, role, destination, state.mode)
|
||||
projectedDestination := destination.clone()
|
||||
if placement == placementModeSequenceItem {
|
||||
projectedDestination = projectedDestination.Index(0)
|
||||
}
|
||||
result := processSourceVersion(root, state.localRule, role, projectedDestination, state.mode)
|
||||
if result.evidence != nil {
|
||||
result.evidence.sourceID = sourceID
|
||||
state.evidence = append(state.evidence, result.evidence)
|
||||
@@ -119,6 +123,10 @@ type sourceVersionProcessingResult struct {
|
||||
}
|
||||
|
||||
func effectiveSourceVersionRule(local *VersionRule, destination Path, mode sourceVersionMode) *VersionRule {
|
||||
return effectiveSourceVersionRuleForPlacement(local, destination, mode, placementModeMapping)
|
||||
}
|
||||
|
||||
func effectiveSourceVersionRuleForPlacement(local *VersionRule, destination Path, mode sourceVersionMode, placement placementMode) *VersionRule {
|
||||
if local == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -126,9 +134,13 @@ func effectiveSourceVersionRule(local *VersionRule, destination Path, mode sourc
|
||||
return local
|
||||
}
|
||||
effective := *local
|
||||
prefix := destination.clone()
|
||||
if placement == placementModeSequenceItem {
|
||||
prefix = prefix.Index(0)
|
||||
}
|
||||
effective.Path = Path{
|
||||
segments: append(clonePathSegments(destination.segments, len(local.Path.segments)), local.Path.segments...),
|
||||
invalid: destination.invalid || local.Path.invalid,
|
||||
segments: append(clonePathSegments(prefix.segments, len(local.Path.segments)), local.Path.segments...),
|
||||
invalid: prefix.invalid || local.Path.invalid,
|
||||
}
|
||||
return &effective
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user