Search in sources :

Example 86 with Error

use of com.google.privacy.dlp.v2.Error in project dodo by devhawala.

the class DodoTest method testBfsChsService.

private static void testBfsChsService() throws XnsException {
    ChsDatabase chsDatabase = new ChsDatabase(0x1122_3344, "organization", "domain", null, true);
    Clearinghouse3Impl.init(0x1122_3344, 0xAABB_CCDD_EEFFL, chsDatabase);
    localSite.pexListen(IDP.KnownSocket.CLEARINGHOUSE.getSocket(), new BfsClearinghouseResponder());
    byte[] requestData = { 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x56, 0x78, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00 };
    Payload response = localSite.pexRequest(IDP.BROADCAST_ADDR, IDP.KnownSocket.CLEARINGHOUSE.getSocket(), PEX.ClientType.CLEARINGHOUSE.getTypeValue(), requestData, 0, requestData.length);
    if (response == null) {
        System.out.println("bfs response: null (timeout)\n");
    } else if (response instanceof PEX) {
        System.out.println("bfs response is of type: PEX\n");
        PEX pex = (PEX) response;
        System.out.printf("=> PEX: %s\n", pex.toString());
        System.out.printf("=> PEX.payload: %s\n", pex.payloadToString());
    } else if (response instanceof Error) {
        System.out.println("bfs response is of type: Error\n");
    } else {
        System.out.printf("bfs response is of unexpected type: %s\n", response.getClass().getName());
    }
}
Also used : PEX(dev.hawala.xns.level2.PEX) BfsClearinghouseResponder(dev.hawala.xns.level4.chs.BfsClearinghouseResponder) Error(dev.hawala.xns.level2.Error) Payload(dev.hawala.xns.level0.Payload) ChsDatabase(dev.hawala.xns.level4.common.ChsDatabase)

Example 87 with Error

use of com.google.privacy.dlp.v2.Error in project dodo by devhawala.

the class XnsTestRequestor method doTimeServiceRequest.

private static void doTimeServiceRequest() throws XnsException {
    System.out.println("\n## sending Time service request");
    byte[] requestData = { // time serice version 2
    0x00, // time serice version 2
    0x02, // request
    0x00, // request
    0x01 };
    Payload response = localSite.pexRequest(IDP.BROADCAST_ADDR, IDP.KnownSocket.TIME.getSocket(), PEX.ClientType.TIME.getTypeValue(), requestData, 0, requestData.length);
    if (response == null) {
        System.out.println("=> time response: null (timeout)\n");
    } else if (response instanceof PEX) {
        System.out.println("=> time response:");
        PEX pex = (PEX) response;
        System.out.println(pex.toString());
        System.out.printf("=> PEX.payload: %s\n", pex.payloadToString());
    } else if (response instanceof Error) {
        System.out.println("=> time response is of type: Error\n");
    } else {
        System.out.printf("=> time response is of unexpected type: %s\n", response.getClass().getName());
    }
}
Also used : PEX(dev.hawala.xns.level2.PEX) Error(dev.hawala.xns.level2.Error) Payload(dev.hawala.xns.level0.Payload)

Example 88 with Error

use of com.google.privacy.dlp.v2.Error in project auto-data-tokenize by GoogleCloudPlatform.

the class DlpInspectionPipeline method makePipeline.

/**
 * Creates the pipeline and applies the transforms.
 */
@VisibleForTesting
Pipeline makePipeline() {
    TupleTag<FlatRecord> recordsTag = new TupleTag<>();
    TupleTag<String> avroSchemaTag = new TupleTag<>();
    PCollectionTuple recordSchemaTuple = pipeline.apply("Read" + SourceNames.forType(options.getSourceType()).asCamelCase(), TransformingReader.forSourceType(options.getSourceType()).from(options.getInputPattern()).withJdbcConfiguration(JdbcConfigurationExtractor.using(options).jdbcConfiguration()).withSecretsClient(secretsClient).withRecordsTag(recordsTag).withAvroSchemaTag(avroSchemaTag));
    // Sample and Identify columns
    var columnInfoTag = new TupleTag<ColumnInformation>();
    var errorTag = new TupleTag<KV<ShardedKey<String>, Table>>();
    var dlpInspectResults = recordSchemaTuple.get(recordsTag).apply("RandomColumnarSample", RandomColumnarSampler.any(options.getSampleSize())).apply("BatchForDlp", new BatchColumnsForDlp()).apply("DlpIdentify", DlpIdentify.builder().batchIdentifierFactory(makeDlpBatchIdentifierFactory()).columnInfoTag(columnInfoTag).errorTag(errorTag).build());
    dlpInspectResults.get(errorTag).setCoder(KvCoder.of(ShardedKey.Coder.of(StringUtf8Coder.of()), ProtoCoder.of(Table.class))).apply("MakeErrorTableJson", ParDo.of(new ConvertTableToJsonFn())).setCoder(KvCoder.of(StringUtf8Coder.of(), StringUtf8Coder.of())).apply("WriteErrorElements", FileIO.<String, KV<String, String>>writeDynamic().via(Contextful.fn(KV::getValue), Contextful.fn(col -> TextIO.sink())).by(KV::getKey).withDestinationCoder(StringUtf8Coder.of()).withNaming(Contextful.fn(colName -> defaultNaming(/*prefix=*/
    String.format("col-%s", colName.replaceAll("[\\.\\$\\[\\]]+", "-")).replaceAll("[-]+", "-"), /*suffix=*/
    ".json"))).to(options.getReportLocation() + "/error"));
    var inspectionReport = dlpInspectResults.get(columnInfoTag).apply("ExtractReport", MakeInspectionReport.builder().setAvroSchema(recordSchemaTuple.get(avroSchemaTag).apply(View.asSingleton())).setSourceType(options.getSourceType()).setClock(clock).setInputPattern(options.getInputPattern()).setJdbcConfiguration(JdbcConfigurationExtractor.using(options).jdbcConfiguration()).build());
    recordSchemaTuple.get(avroSchemaTag).apply("WriteSchema", TextIO.write().to(options.getReportLocation() + "/schema").withSuffix(".json").withoutSharding());
    writeReportToGcs(inspectionReport);
    writeReportToBigQuery(inspectionReport);
    writeReportToDataCatalog(inspectionReport);
    return pipeline;
}
Also used : FileIO(org.apache.beam.sdk.io.FileIO) KV(org.apache.beam.sdk.values.KV) DlpBatchInspectFactory(com.google.cloud.solutions.autotokenize.dlp.DlpBatchInspectFactory) InspectionReportToTableRow(com.google.cloud.solutions.autotokenize.common.InspectionReportToTableRow) View(org.apache.beam.sdk.transforms.View) PipelineOptionsFactory(org.apache.beam.sdk.options.PipelineOptionsFactory) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) SecretsClient(com.google.cloud.solutions.autotokenize.common.SecretsClient) Contextful(org.apache.beam.sdk.transforms.Contextful) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) DlpClientFactory(com.google.cloud.solutions.autotokenize.dlp.DlpClientFactory) TransformingReader(com.google.cloud.solutions.autotokenize.common.TransformingReader) TupleTag(org.apache.beam.sdk.values.TupleTag) InspectionReport(com.google.cloud.solutions.autotokenize.AutoTokenizeMessages.InspectionReport) ProtoCoder(org.apache.beam.sdk.extensions.protobuf.ProtoCoder) DataCatalogWriter(com.google.cloud.solutions.autotokenize.datacatalog.DataCatalogWriter) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ColumnInformation(com.google.cloud.solutions.autotokenize.AutoTokenizeMessages.ColumnInformation) Pipeline(org.apache.beam.sdk.Pipeline) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) DoFn(org.apache.beam.sdk.transforms.DoFn) MakeDataCatalogItems(com.google.cloud.solutions.autotokenize.datacatalog.MakeDataCatalogItems) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) KvCoder(org.apache.beam.sdk.coders.KvCoder) ImmutableSet(com.google.common.collect.ImmutableSet) BatchColumnsForDlp(com.google.cloud.solutions.autotokenize.dlp.BatchColumnsForDlp) BigQueryIO(org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO) Table(com.google.privacy.dlp.v2.Table) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) DlpIdentify(com.google.cloud.solutions.autotokenize.dlp.DlpIdentify) InfoType(com.google.privacy.dlp.v2.InfoType) CreateDisposition(org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.CreateDisposition) ShardedKey(org.apache.beam.sdk.util.ShardedKey) PCollection(org.apache.beam.sdk.values.PCollection) Write.defaultNaming(org.apache.beam.sdk.io.FileIO.Write.defaultNaming) GoogleLogger(com.google.common.flogger.GoogleLogger) SourceNames(com.google.cloud.solutions.autotokenize.common.SourceNames) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) JsonFormat(com.google.protobuf.util.JsonFormat) ParDo(org.apache.beam.sdk.transforms.ParDo) WriteDisposition(org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition) FlatRecord(com.google.cloud.solutions.autotokenize.AutoTokenizeMessages.FlatRecord) Clock(java.time.Clock) InspectionReportFileWriter(com.google.cloud.solutions.autotokenize.common.InspectionReportFileWriter) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TextIO(org.apache.beam.sdk.io.TextIO) Table(com.google.privacy.dlp.v2.Table) FlatRecord(com.google.cloud.solutions.autotokenize.AutoTokenizeMessages.FlatRecord) TupleTag(org.apache.beam.sdk.values.TupleTag) KV(org.apache.beam.sdk.values.KV) ShardedKey(org.apache.beam.sdk.util.ShardedKey) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) BatchColumnsForDlp(com.google.cloud.solutions.autotokenize.dlp.BatchColumnsForDlp) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 89 with Error

use of com.google.privacy.dlp.v2.Error in project vnfsdk-validation by onap.

the class VTPValidateCSARR130206 method validateCSAR.

@Override
protected void validateCSAR(CSARArchive csar) throws OnapCommandException {
    try {
        final Optional<Path> pathToCsarFolder = getPathToCsar(csar);
        if (pathToCsarFolder.isPresent()) {
            final CsarSecurityValidator csarSecurityValidator = new CsarSecurityValidator(csar, pathToCsarFolder.get());
            this.errors.addAll(csarSecurityValidator.validate());
        } else {
            this.errors.add(new Error.CSARErrorUnableToFindCsarContent());
        }
    } catch (Exception e) {
        LOG.error("Internal VTPValidateCSARR130206 command error", e);
        throw new OnapCommandException("0x3000", "Internal VTPValidateCSARR130206 command error. See logs.");
    }
}
Also used : Path(java.nio.file.Path) CsarSecurityValidator(org.onap.cvc.csar.cc.sol004.r130206.CsarSecurityValidator) Error(org.onap.cvc.csar.cc.sol004.r130206.Error) OnapCommandException(org.onap.cli.fw.error.OnapCommandException) OnapCommandException(org.onap.cli.fw.error.OnapCommandException)

Aggregations

ArrayList (java.util.ArrayList)28 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)23 Test (org.junit.Test)23 ParseException (org.apache.commons.cli.ParseException)18 AbstractMessage (com.google.protobuf.AbstractMessage)16 DlpJob (com.google.privacy.dlp.v2.DlpJob)15 InfoType (com.google.privacy.dlp.v2.InfoType)13 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)12 ByteString (com.google.protobuf.ByteString)12 Error (dev.hawala.xns.level2.Error)12 Error (org.ovirt.engine.sdk4.Error)12 InspectConfig (com.google.privacy.dlp.v2.InspectConfig)11 Error (org.eclipse.bpmn2.Error)11 ContentItem (com.google.privacy.dlp.v2.ContentItem)10 ProjectName (com.google.privacy.dlp.v2.ProjectName)9 Iterator (java.util.Iterator)9 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)8 RootElement (org.eclipse.bpmn2.RootElement)8 Error (com.google.privacy.dlp.v2.Error)7 ServiceOptions (com.google.cloud.ServiceOptions)6