static void Main(string[] args) { Menu.Hello(); JSONRulesReader jra = new JSONRulesReader(@"D:\Storage\FIA UES\project\QA_ANDROID\FIA_APK_QA\QA_FIA_APK_CONSOLE\VerificationRules\Android"); //ClassTextReader ctr = new ClassTextReader(@"C:\Users\Marcos\Desktop\IVerificable.cs"); VerifyAction va = new VerifyAction(jra.METRIC_DATA); Console.WriteLine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); var files = jra.METRIC_FILES; jra.read(); var metricInfo = va.StartVerifications(); foreach (MetricInfo info in metricInfo) { Console.WriteLine("======================================"); Console.WriteLine($"Metrica: {info.Name}"); Console.WriteLine($"Descripción: {info.Description}"); Console.WriteLine($"Operación: {info.Operation}"); Console.WriteLine($"Archivo: {info.File}"); Console.WriteLine($"Resultado: {info.Result}"); } Console.ReadKey(); }
private static async Task <int> OnExecuteAsync(Options options) { if (!options.ListKeys && !options.Sign && !options.VerifySignature) { throw new Exception(Resources.ValidCommandAction); } GpgOutputHelper.FileDescriptor = options.StatusFileDescriptor; try { int result = 1; if (options.ListKeys) { result = await ListKeysAction.Do().ConfigureAwait(false); } if (options.Sign) { result = await SignAction.Do(options.FileNames.FirstOrDefault(), options.LocalUser, options.GetTimestampAuthorityUri(), options.DetachedSign, options.Armor, options.IncludeOption).ConfigureAwait(false); } if (options.VerifySignature) { result = VerifyAction.Do(options.FileNames.ToArray()); } if (result == 1) { throw new Exception(Resources.ValidCommandAction); } return(result); } catch (SignClientException ex) { InfoOutputHelper.WriteLine(ex.ToString()); TelemetryHelper.Client?.TrackException(ex); } catch (Exception ex) { InfoOutputHelper.WriteLine(ex.ToString()); // Don't pass the exception in the generic case, due to it might contain personal information. TelemetryHelper.Client?.TrackTrace(ex.GetType().FullName, SeverityLevel.Critical); } return(1); }
public WhenPendingFeaturesStillExistAfterUpdatingFromLocalCacheTests() { featureOne = Guid.NewGuid(); featureTwo = Guid.NewGuid(); featureThree = Guid.NewGuid(); var httpClient = Substitute.For <IHttpClient>(); string keyPair = Helpers.GenerateKeyPairXml(); var domainLicense = Helpers.GenerateDomainLicense(new List <Guid> { featureOne, featureThree }); httpClient.Send(Arg.Any <HttpRequest>()).Returns(new HttpResponse { Content = Helpers.GenerateValidXmlResponseFromKeyHub(keyPair, new List <DomainLicense> { domainLicense }) }); licenseStore = Substitute.For <ILicenseStore>(); licenseStore.GetLicenses().Returns(new List <byte[]>()); var featureStates = new Dictionary <string, Dictionary <Guid, FeatureState> > { { "domain.com", new Dictionary <Guid, FeatureState> { { featureOne, FeatureState.Pending }, { featureTwo, FeatureState.Pending }, { featureThree, FeatureState.Pending } } } }; var pendingFeatures = new Dictionary <string, List <Guid> > { { "domain.com", new List <Guid> { featureOne, featureTwo, featureThree } } }; verifyAction = new VerifyAction(httpClient, keyPair, Guid.NewGuid(), licenseStore, featureStates, pendingFeatures); verifyAction.Finished += verifyAction_Finished; }
private static async Task <int> OnExecuteAsync(Options options) { if (!options.ListKeys && !options.Sign && !options.VerifySignature) { throw new Exception(Resources.ValidCommandAction); } GpgOutputHelper.FileDescriptor = options.StatusFileDescriptor; try { int result = 1; if (options.ListKeys) { result = await ListKeysAction.Do().ConfigureAwait(false); } if (options.Sign) { result = await SignAction.Do(options.FileNames.FirstOrDefault(), options.LocalUser, options.GetTimestampAuthorityUri(), options.DetachedSign, options.Armor, options.IncludeOption).ConfigureAwait(false); } if (options.VerifySignature) { result = VerifyAction.Do(options.FileNames.ToArray()); } if (result == 1) { throw new Exception(Resources.ValidCommandAction); } return(result); } catch (SignClientException ex) { InfoOutputHelper.WriteLine(ex.ToString()); } catch (Exception ex) { InfoOutputHelper.WriteLine(ex.ToString()); } return(1); }
public async Task TestSignAndVerifyPemDetached() { var(outputStream, gpgStream) = GetOutputStreams(); var certificate = Generate(); var bytes = Encoding.UTF8.GetBytes("Hello World"); var result = await SignAction.PerformSign(certificate, bytes, null, true, true, X509IncludeOption.WholeChain).ConfigureAwait(false); Assert.Equal(0, result); var output = GetStreamContents(outputStream); var gpg = GetStreamContents(gpgStream); output.ShouldBeEmpty(); gpg.ShouldNotBeEmpty(); var signature = gpg.Substring(gpg.IndexOf("-----BEGIN SIGNED MESSAGE-----", StringComparison.InvariantCulture)); var signatureBytes = Encoding.Default.GetBytes(signature); Should.NotThrow(() => VerifyAction.VerifyDetached(signatureBytes, bytes, true)); }
public WhenLocalCacheContainsLicenseInformationTests() { featureOne = Guid.NewGuid(); featureTwo = Guid.NewGuid(); featureThree = Guid.NewGuid(); featureFour = Guid.NewGuid(); featureFive = Guid.NewGuid(); featureSix = Guid.NewGuid(); featureSeven = Guid.NewGuid(); var httpClient = Substitute.For <IHttpClient>(); string keyPair = Helpers.GenerateKeyPairXml(); // featureOne and featureThree belong to an expired license var expiredDomainLicense = new DomainLicense( "expired.com", "John Doe", DateTime.UtcNow.AddYears(-1), DateTime.UtcNow.AddHours(24).AddYears(-1), new List <Guid> { featureOne, featureThree } ); var issued = DateTime.UtcNow; var expires = DateTime.UtcNow.AddHours(24); // featureTwo and featureFive have already been verified var cachedDomainLicense = new DomainLicense( "domain.com", "John Doe", issued, expires, new List <Guid> { featureTwo, featureFive } ); // featureSix and featureSeven are Pending, but only featureSix will be enabled var keyHubDomainLicense = new DomainLicense( "domain.com", "John Doe", issued, expires, new List <Guid> { featureTwo, featureFour, // Rejected in the past is now enabled featureFive, featureSix // Pending new feature } ); httpClient.Send(Arg.Any <HttpRequest>()).Returns(new HttpResponse { Content = Helpers.GenerateValidXmlResponseFromKeyHub(keyPair, new List <DomainLicense> { keyHubDomainLicense }) }); licenseStore = Substitute.For <ILicenseStore>(); licenseStore.GetLicenses().Returns(new List <byte[]> { expiredDomainLicense.SerializeAndEncrypt(keyPair), cachedDomainLicense.SerializeAndEncrypt(keyPair) }); var featureStates = new Dictionary <string, Dictionary <Guid, FeatureState> > { { "expired.com", new Dictionary <Guid, FeatureState> { { featureOne, FeatureState.Enabled }, { featureThree, FeatureState.Enabled } } }, { "domain.com", new Dictionary <Guid, FeatureState> { { featureTwo, FeatureState.Enabled }, { featureFour, FeatureState.Rejected }, { featureFive, FeatureState.Enabled }, { featureSix, FeatureState.Pending }, { featureSeven, FeatureState.Pending } } } }; var pendingFeatures = new Dictionary <string, List <Guid> > { { "domain.com", new List <Guid> { featureSix, featureSeven } } }; verifyAction = new VerifyAction(httpClient, keyPair, Guid.NewGuid(), licenseStore, featureStates, pendingFeatures); verifyAction.Finished += verifyAction_Finished; }
public VerifyCommand() : base(Name, Description) { this.SetHandler(() => VerifyAction.Run()); }
public Analyzer() { jrr = new JSONRulesReader($@"{AppDomain.CurrentDomain.BaseDirectory}VerificationRules\Android"); jrr.read(); va = new VerifyAction(jrr.METRIC_DATA); }