// Methods /// <summary> /// Run security verification on this assembly using the specified security restrictions. /// </summary> /// <param name="restrictions">The restrictions used to verify the assembly</param> /// <returns>True if the assembly passes security verification or false if it fails</returns> public bool SecurityCheckAssembly(CodeSecurityRestrictions restrictions) { // Check for already checked if (securityEngine == null) { return(isSecurityValidated); } // Run code valdiation isSecurityValidated = securityEngine.SecurityCheckAssembly(restrictions); // Release security engine securityEngine = null; return(isSecurityValidated); }
/// <summary> /// Run security verification on this assembly using the specified security restrictions and output a security report /// </summary> /// <param name="restrictions">The restrictions used to verify the assembly</param> /// <param name="report">The security report generated by the assembly checker</param> /// <returns>True if the assembly passes security verification or false if it fails</returns> public bool SecurityCheckAssembly(CodeSecurityRestrictions restrictions, out CodeSecurityReport report) { // Skip checks if (isSecurityValidated == true && restrictions.RestrictionsHash == securityValidatedHash) { report = securityReport; return(true); } // Create the security engine CodeSecurityEngine securityEngine = CreateSecurityEngine(); // Check for already checked if (securityEngine == null) { report = securityReport; return(isSecurityValidated); } // Must dispose once finished using (securityEngine) { // Run code valdiation isSecurityValidated = securityEngine.SecurityCheckAssembly(restrictions, out securityReport); // Check for verified if (isSecurityValidated == true) { // Store the hash so that the same restirctions will not need to run again securityValidatedHash = restrictions.RestrictionsHash; } else { securityValidatedHash = -1; } report = securityReport; return(isSecurityValidated); } }