Loading tools/compliance/cmd/listshare/listshare.go +3 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,9 @@ func listShare(stdout, stderr io.Writer, rootFS fs.FS, files ...string) error { // Group the resolutions by project. presolution := make(map[string]compliance.LicenseConditionSet) for _, target := range shareSource.AttachesTo() { if shareSource.IsPureAggregate(target) && !target.LicenseConditions().MatchesAnySet(compliance.ImpliesShared) { continue } rl := shareSource.Resolutions(target) sort.Sort(rl) for _, r := range rl { Loading tools/compliance/cmd/listshare/listshare_test.go +0 −38 Original line number Diff line number Diff line Loading @@ -193,13 +193,6 @@ func Test(t *testing.T) { project: "dynamic/binary", conditions: []string{"restricted"}, }, { project: "highest/apex", conditions: []string{ "restricted", "restricted_allows_dynamic_linking", }, }, { project: "static/binary", conditions: []string{ Loading @@ -224,13 +217,6 @@ func Test(t *testing.T) { project: "base/library", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{ "restricted", "restricted_allows_dynamic_linking", }, }, { project: "device/library", conditions: []string{"restricted_allows_dynamic_linking"}, Loading Loading @@ -320,10 +306,6 @@ func Test(t *testing.T) { project: "dynamic/binary", conditions: []string{"restricted"}, }, { project: "highest/apex", conditions: []string{"restricted"}, }, }, }, { Loading @@ -335,10 +317,6 @@ func Test(t *testing.T) { project: "base/library", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "dynamic/binary", conditions: []string{"restricted"}, Loading Loading @@ -381,10 +359,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, }, }, { Loading @@ -396,10 +370,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading @@ -419,10 +389,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading @@ -446,10 +412,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading tools/compliance/policy_resolve.go +6 −18 Original line number Diff line number Diff line Loading @@ -65,9 +65,7 @@ func TraceBottomUpConditions(lg *LicenseGraph, conditionsFn TraceConditions) { // amap identifes targets previously walked. (guarded by mu) amap := make(map[*TargetNode]struct{}) // cmap identifies targets previously walked as pure aggregates. i.e. as containers // (guarded by mu) cmap := make(map[*TargetNode]struct{}) // mu guards concurrent access to amap var mu sync.Mutex var walk func(target *TargetNode, treatAsAggregate bool) LicenseConditionSet Loading @@ -81,19 +79,16 @@ func TraceBottomUpConditions(lg *LicenseGraph, conditionsFn TraceConditions) { if treatAsAggregate { return target.resolution, true } if _, asAggregate := cmap[target]; !asAggregate { if !target.pure { return target.resolution, true } // previously walked in a pure aggregate context, // needs to walk again in non-aggregate context delete(cmap, target) } else { target.resolution |= conditionsFn(target) amap[target] = struct{}{} } if treatAsAggregate { cmap[target] = struct{}{} } target.pure = treatAsAggregate return target.resolution, false } cs, alreadyWalked := priorWalkResults() Loading Loading @@ -169,11 +164,7 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { // amap contains the set of targets already walked. (guarded by mu) amap := make(map[*TargetNode]struct{}) // cmap contains the set of targets walked as pure aggregates. i.e. containers // (guarded by mu) cmap := make(map[*TargetNode]struct{}) // mu guards concurrent access to cmap // mu guards concurrent access to amap var mu sync.Mutex var walk func(fnode *TargetNode, cs LicenseConditionSet, treatAsAggregate bool) Loading @@ -183,10 +174,8 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { mu.Lock() fnode.resolution |= conditionsFn(fnode) fnode.resolution |= cs fnode.pure = treatAsAggregate amap[fnode] = struct{}{} if treatAsAggregate { cmap[fnode] = struct{}{} } cs = fnode.resolution mu.Unlock() // for each dependency Loading @@ -208,11 +197,10 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { return } // non-aggregates don't need walking as non-aggregate a 2nd time if _, asAggregate := cmap[dnode]; !asAggregate { if !dnode.pure { return } // previously walked as pure aggregate; need to re-walk as non-aggregate delete(cmap, dnode) } } // add the conditions to the dependency Loading tools/compliance/policy_shareprivacyconflicts.go +8 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,11 @@ func ConflictingSharedPrivateSource(lg *LicenseGraph) []SourceSharePrivacyConfli // size is the size of the result size := 0 for _, cs := range combined { for actsOn, cs := range combined { if actsOn.pure && !actsOn.LicenseConditions().MatchesAnySet(ImpliesShared) { // no need to share code to build "a distribution medium" continue } size += cs.Intersection(ImpliesShared).Len() * cs.Intersection(ImpliesPrivate).Len() } if size == 0 { Loading @@ -57,6 +61,9 @@ func ConflictingSharedPrivateSource(lg *LicenseGraph) []SourceSharePrivacyConfli } result := make([]SourceSharePrivacyConflict, 0, size) for actsOn, cs := range combined { if actsOn.pure { // no need to share code for "a distribution medium" continue } pconditions := cs.Intersection(ImpliesPrivate).AsList() ssconditions := cs.Intersection(ImpliesShared).AsList() Loading tools/compliance/readgraph.go +3 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,9 @@ type targetNode struct { // resolution identifies the set of conditions resolved by acting on the target node. resolution LicenseConditionSet // pure indicates whether to treat the node as a pure aggregate (no internal linkage) pure bool } // addDependencies converts the proto AnnotatedDependencies into `edges` Loading Loading
tools/compliance/cmd/listshare/listshare.go +3 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,9 @@ func listShare(stdout, stderr io.Writer, rootFS fs.FS, files ...string) error { // Group the resolutions by project. presolution := make(map[string]compliance.LicenseConditionSet) for _, target := range shareSource.AttachesTo() { if shareSource.IsPureAggregate(target) && !target.LicenseConditions().MatchesAnySet(compliance.ImpliesShared) { continue } rl := shareSource.Resolutions(target) sort.Sort(rl) for _, r := range rl { Loading
tools/compliance/cmd/listshare/listshare_test.go +0 −38 Original line number Diff line number Diff line Loading @@ -193,13 +193,6 @@ func Test(t *testing.T) { project: "dynamic/binary", conditions: []string{"restricted"}, }, { project: "highest/apex", conditions: []string{ "restricted", "restricted_allows_dynamic_linking", }, }, { project: "static/binary", conditions: []string{ Loading @@ -224,13 +217,6 @@ func Test(t *testing.T) { project: "base/library", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{ "restricted", "restricted_allows_dynamic_linking", }, }, { project: "device/library", conditions: []string{"restricted_allows_dynamic_linking"}, Loading Loading @@ -320,10 +306,6 @@ func Test(t *testing.T) { project: "dynamic/binary", conditions: []string{"restricted"}, }, { project: "highest/apex", conditions: []string{"restricted"}, }, }, }, { Loading @@ -335,10 +317,6 @@ func Test(t *testing.T) { project: "base/library", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "dynamic/binary", conditions: []string{"restricted"}, Loading Loading @@ -381,10 +359,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, }, }, { Loading @@ -396,10 +370,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading @@ -419,10 +389,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading @@ -446,10 +412,6 @@ func Test(t *testing.T) { project: "bin/threelibraries", conditions: []string{"restricted"}, }, { project: "container/zip", conditions: []string{"restricted"}, }, { project: "lib/apache", conditions: []string{"restricted"}, Loading
tools/compliance/policy_resolve.go +6 −18 Original line number Diff line number Diff line Loading @@ -65,9 +65,7 @@ func TraceBottomUpConditions(lg *LicenseGraph, conditionsFn TraceConditions) { // amap identifes targets previously walked. (guarded by mu) amap := make(map[*TargetNode]struct{}) // cmap identifies targets previously walked as pure aggregates. i.e. as containers // (guarded by mu) cmap := make(map[*TargetNode]struct{}) // mu guards concurrent access to amap var mu sync.Mutex var walk func(target *TargetNode, treatAsAggregate bool) LicenseConditionSet Loading @@ -81,19 +79,16 @@ func TraceBottomUpConditions(lg *LicenseGraph, conditionsFn TraceConditions) { if treatAsAggregate { return target.resolution, true } if _, asAggregate := cmap[target]; !asAggregate { if !target.pure { return target.resolution, true } // previously walked in a pure aggregate context, // needs to walk again in non-aggregate context delete(cmap, target) } else { target.resolution |= conditionsFn(target) amap[target] = struct{}{} } if treatAsAggregate { cmap[target] = struct{}{} } target.pure = treatAsAggregate return target.resolution, false } cs, alreadyWalked := priorWalkResults() Loading Loading @@ -169,11 +164,7 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { // amap contains the set of targets already walked. (guarded by mu) amap := make(map[*TargetNode]struct{}) // cmap contains the set of targets walked as pure aggregates. i.e. containers // (guarded by mu) cmap := make(map[*TargetNode]struct{}) // mu guards concurrent access to cmap // mu guards concurrent access to amap var mu sync.Mutex var walk func(fnode *TargetNode, cs LicenseConditionSet, treatAsAggregate bool) Loading @@ -183,10 +174,8 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { mu.Lock() fnode.resolution |= conditionsFn(fnode) fnode.resolution |= cs fnode.pure = treatAsAggregate amap[fnode] = struct{}{} if treatAsAggregate { cmap[fnode] = struct{}{} } cs = fnode.resolution mu.Unlock() // for each dependency Loading @@ -208,11 +197,10 @@ func TraceTopDownConditions(lg *LicenseGraph, conditionsFn TraceConditions) { return } // non-aggregates don't need walking as non-aggregate a 2nd time if _, asAggregate := cmap[dnode]; !asAggregate { if !dnode.pure { return } // previously walked as pure aggregate; need to re-walk as non-aggregate delete(cmap, dnode) } } // add the conditions to the dependency Loading
tools/compliance/policy_shareprivacyconflicts.go +8 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,11 @@ func ConflictingSharedPrivateSource(lg *LicenseGraph) []SourceSharePrivacyConfli // size is the size of the result size := 0 for _, cs := range combined { for actsOn, cs := range combined { if actsOn.pure && !actsOn.LicenseConditions().MatchesAnySet(ImpliesShared) { // no need to share code to build "a distribution medium" continue } size += cs.Intersection(ImpliesShared).Len() * cs.Intersection(ImpliesPrivate).Len() } if size == 0 { Loading @@ -57,6 +61,9 @@ func ConflictingSharedPrivateSource(lg *LicenseGraph) []SourceSharePrivacyConfli } result := make([]SourceSharePrivacyConflict, 0, size) for actsOn, cs := range combined { if actsOn.pure { // no need to share code for "a distribution medium" continue } pconditions := cs.Intersection(ImpliesPrivate).AsList() ssconditions := cs.Intersection(ImpliesShared).AsList() Loading
tools/compliance/readgraph.go +3 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,9 @@ type targetNode struct { // resolution identifies the set of conditions resolved by acting on the target node. resolution LicenseConditionSet // pure indicates whether to treat the node as a pure aggregate (no internal linkage) pure bool } // addDependencies converts the proto AnnotatedDependencies into `edges` Loading