示例#1
0
        public EvaluatedPackage Apply(LicensedPackage package)
        {
            if (this.packagePolicies.IgnorePackage(package.Id))
            {
                Log.Warning($"Package {package.Id} is ignored but is still evaluated for license.");
                return(new EvaluatedPackage(package, Evaluation.Ignored));
            }

            if (this.packagePolicies.AllowLicense(package.Id))
            {
                return(new EvaluatedPackage(package, Evaluation.Ok, "Package license explicitly allowed"));
            }

            LicensePolicy policy = this.policies.FirstOrDefault(r => r.IsMatch(package.License));

            if (policy == null)
            {
                return(new EvaluatedPackage(package, Evaluation.Violation, "No policy found"));
            }

            if (policy.License.Equals(License.UnknownLicenseStr) && !policy.Allow)
            {
                return(new EvaluatedPackage(package, Evaluation.Violation, "Could not find license"));
            }

            if (policy.AllowInternal && this.projects.Contains(package.OriginProject))
            {
                return(new EvaluatedPackage(package, Evaluation.Ok));
            }

            return(new EvaluatedPackage(package, policy.Allow ? Evaluation.Ok : Evaluation.Violation));
        }
 public EvaluatedPackage(LicensedPackage package, Evaluation result, string remark = "") : base(package)
 {
     Result = result;
     Remark = remark;
 }
 public LicensedPackage(LicensedPackage other) : base(other.Id, other.Version, other.OriginProject)
 {
     License = other.License;
 }