Skip to content

Commit f6d90ed

Browse files
authored
dlp: Update README instructions to remove uberjar info (GoogleCloudPlatform#3167)
Fixes #issue > It's a good idea to open an issue first for discussion. - [x] I have followed [Sample Format Guide](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/SAMPLE_FORMAT.md) - [x] `pom.xml` parent set to latest `shared-configuration` - [x] Appropriate changes to README are included in PR - [ ] API's need to be enabled to test (tell us) - [ ] Environment Variables need to be set (ask us to set them) - [x] **Tests** pass: `mvn clean verify` **required** - [x] **Lint** passes: `mvn -P lint checkstyle:check` **required** - [ ] **Static Analysis**: `mvn -P lint clean compile pmd:cpd-check spotbugs:check` **advisory only** - [x] Please **merge** this PR for me once it is approved.
1 parent e657a6c commit f6d90ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+63
-128
lines changed

dlp/README.md

+12-48
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,27 @@ a powerful detection engine for personally identifiable information and other pr
1010
## Setup
1111
- A Google Cloud project with billing enabled
1212
- [Enable](https://console.cloud.google.com/launcher/details/google/dlp.googleapis.com) the DLP API.
13-
- (Local testing) [Create a service account](https://cloud.google.com/docs/authentication/getting-started)
13+
- [Create a service account](https://cloud.google.com/docs/authentication/getting-started)
1414
and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to the downloaded credentials file.
15-
- (Local testing) Set the `DLP_DEID_WRAPPED_KEY` environment variable to an AES-256 key encrypted ('wrapped') [with a Cloud Key Management Service (KMS) key](https://cloud.google.com/kms/docs/encrypt-decrypt).
16-
- (Local testing) Set the `DLP_DEID_KEY_NAME` environment variable to the path-name of the Cloud KMS key you wrapped `DLP_DEID_WRAPPED_KEY` with.
1715

18-
## Build
19-
This project uses the [Assembly Plugin](https://maven.apache.org/plugins/maven-assembly-plugin/usage.html) to build an uber jar.
20-
Run:
21-
```
22-
mvn clean package -DskipTests
23-
```
24-
25-
## Retrieve InfoTypes
26-
An [InfoType identifier](https://cloud.google.com/dlp/docs/infotypes-categories) represents an element of sensitive data.
27-
28-
[InfoTypes](https://cloud.google.com/dlp/docs/infotypes-reference#global) are updated periodically. Use the API to retrieve the most current InfoTypes.
29-
```
30-
java -cp target/dlp-samples-1.0-jar-with-dependencies.jar dlp.snippets.InfoTypesList
31-
```
32-
33-
## Run the quickstart
34-
35-
The Quickstart demonstrates using the DLP API to identify an InfoType in a given string.
16+
## Running
3617

37-
Note that you will need to set the `projectId` in
38-
[QuickStart.java](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/dlp/src/main/java/dlp/snippets/QuickStart.java)
39-
for this to work correctly. If you forget this, you will see a `PERMISSION_DENIED` error.
18+
To run a specific sample, edit any variables under the `TODO(developer):` in the
19+
function at the top of each sample, and then execute the function as convenient.
4020

21+
For example, if using the command line you might use the following (replacing
22+
`<CLASS_NAME>` with the name of the sample):
23+
```bash
24+
mvn exec:java -Dexec.mainClass="dlp.snippets.<CLASS_NAME>"
4125
```
42-
java -cp target/dlp-samples-1.0-jar-with-dependencies.jar dlp.snippets.QuickStart
43-
```
44-
45-
## Inspect data for sensitive elements
46-
Inspect strings, files locally and on Google Cloud Storage, Cloud Datastore, and BigQuery with the DLP API.
47-
48-
Note: image scanning is not currently supported on Google Cloud Storage.
49-
For more information, refer to the [API documentation](https://cloud.google.com/dlp/docs).
50-
Optional flags are explained in [this resource](https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#InspectConfig).
51-
52-
## Automatic redaction of sensitive data from images
53-
[Automatic redaction](https://cloud.google.com/dlp/docs/redacting-sensitive-data-images) produces an output image with sensitive data matches removed.
5426

55-
### Example
56-
- Redact phone numbers and email addresses from `src/test/resources/test.png`:
5727

58-
Note that you will need to set the `projectId` in
59-
[RedactImageFile.java](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/dlp/src/main/java/dlp/snippets/RedactImageFilet.java)
60-
for this to work correctly. If you forget this, you will see a `PERMISSION_DENIED` error.
61-
62-
```
63-
java -cp target/dlp-samples-1.0-jar-with-dependencies.jar dlp.snippets.RedactImageFile
64-
```
28+
## Testing
6529

66-
## Integration tests
6730
### Setup
6831
- Ensure that `GOOGLE_APPLICATION_CREDENTIALS` points to authorized service account credentials file.
32+
- Set the `DLP_DEID_WRAPPED_KEY` environment variable to an AES-256 key encrypted ('wrapped') [with a Cloud Key Management Service (KMS) key](https://cloud.google.com/kms/docs/encrypt-decrypt).
33+
- Set the `DLP_DEID_KEY_NAME` environment variable to the path-name of the Cloud KMS key you wrapped `DLP_DEID_WRAPPED_KEY` with.
6934
- [Create a Google Cloud Storage bucket](https://console.cloud.google.com/storage) and upload [test.txt](src/test/resources/test.txt).
7035
- Set the `GCS_PATH` environment variable to point to the path for the bucket.
7136
- Copy and paste the data below into a CSV file and [create a BigQuery table](https://cloud.google.com/bigquery/docs/loading-data-local) from the file:
@@ -77,7 +42,6 @@ Optional flags are explained in [this resource](https://cloud.google.com/dlp/doc
7742
Joe,(452) 123-1234,3782 2288 1166 3030,35,Male
7843
Marie,(452) 123-1234,8291 3627 8250 1234,35,Female
7944
Carrie,(567) 890-1234,2253 5218 4251 4526,35,Female
80-
8145
```
8246
- Set the `BIGQUERY_DATASET` and `BIGQUERY_TABLE` environment values.
8347
- [Create a Google Cloud Pub/Sub](https://console.cloud.google.com/datastore) topic and and a subscription that is subscribed to the topic.
@@ -88,7 +52,7 @@ Optional flags are explained in [this resource](https://cloud.google.com/dlp/doc
8852
- Update the Datastore kind in [InspectTests.java](src/test/java/dlp/snippets/InspectTests.java).
8953
9054
91-
## Run
55+
### Run
9256
Run all tests:
9357
```
9458
mvn clean verify

dlp/pom.xml

-23
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,6 @@
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939
</properties>
4040

41-
<build>
42-
<plugins>
43-
<plugin>
44-
<artifactId>maven-assembly-plugin</artifactId>
45-
<version>3.3.0</version>
46-
<configuration>
47-
<descriptorRefs>
48-
<descriptorRef>jar-with-dependencies</descriptorRef>
49-
</descriptorRefs>
50-
</configuration>
51-
<executions>
52-
<execution>
53-
<id>make-assembly</id> <!-- this is used for inheritance merges -->
54-
<phase>package</phase> <!-- bind to the packaging phase -->
55-
<goals>
56-
<goal>single</goal>
57-
</goals>
58-
</execution>
59-
</executions>
60-
</plugin>
61-
</plugins>
62-
</build>
63-
6441
<dependencyManagement>
6542
<dependencies>
6643
<dependency>

dlp/src/main/java/dlp/snippets/DeIdentifyTableWithFpe.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
public class DeIdentifyTableWithFpe {
4848

49-
public static void deIdentifyTableWithFpe() throws IOException {
49+
public static void main(String[] args) throws Exception {
5050
// TODO(developer): Replace these variables before running the sample.
5151
String projectId = "your-project-id";
5252
String kmsKeyName =

dlp/src/main/java/dlp/snippets/DeIdentifyTextWithFpe.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class DeIdentifyTextWithFpe {
4242

43-
public static void deIdentifyTextWithFpe() throws IOException {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
String textToDeIdentify = "I'm Gary and my email is gary@example.com";

dlp/src/main/java/dlp/snippets/DeIdentifyWithDateShift.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
public class DeIdentifyWithDateShift {
4949

50-
public static void deIdentifyWithDateShift() throws IOException {
50+
public static void main(String[] args) throws Exception {
5151
// TODO(developer): Replace these variables before running the sample.
5252
String projectId = "your-project-id";
5353
Path inputCsvFile = Paths.get("path/to/your/input/file.csv");

dlp/src/main/java/dlp/snippets/DeIdentifyWithExceptionList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
public class DeIdentifyWithExceptionList {
3939

40-
public static void deIdentifyWithExceptionList() throws IOException {
40+
public static void main(String[] args) throws Exception {
4141
// TODO(developer): Replace these variables before running the sample.
4242
String projectId = "your-project-id";
4343
String textToDeIdentify = "jack@example.org accessed customer record of user5@example.com";

dlp/src/main/java/dlp/snippets/DeIdentifyWithFpe.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class DeIdentifyWithFpe {
4242

43-
public static void deIdentifyWithFpe() throws IOException {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
String textToDeIdentify = "I'm Gary and my email is gary@example.com";

dlp/src/main/java/dlp/snippets/DeIdentifyWithInfoType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
public class DeIdentifyWithInfoType {
3636

37-
public static void deIdentifyWithInfoType() throws IOException {
37+
public static void main(String[] args) throws Exception {
3838
// TODO(developer): Replace these variables before running the sample.
3939
String projectId = "your-project-id";
4040
String textToInspect =

dlp/src/main/java/dlp/snippets/DeIdentifyWithMasking.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class DeIdentifyWithMasking {
3838

39-
public static void deIdentifyWithMasking() throws IOException {
39+
public static void main(String[] args) throws Exception {
4040
// TODO(developer): Replace these variables before running the sample.
4141
String projectId = "your-project-id";
4242
String textToDeIdentify = "My SSN is 372819127";

dlp/src/main/java/dlp/snippets/DeIdentifyWithRedaction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
public class DeIdentifyWithRedaction {
3535

36-
public static void deIdentifyWithRedaction() {
36+
public static void main(String[] args) throws Exception {
3737
// TODO(developer): Replace these variables before running the sample.
3838
String projectId = "your-project-id";
3939
String textToInspect =

dlp/src/main/java/dlp/snippets/DeIdentifyWithReplacement.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
public class DeIdentifyWithReplacement {
3737

38-
public static void deIdentifyWithReplacement() {
38+
public static void main(String[] args) throws Exception {
3939
// TODO(developer): Replace these variables before running the sample.
4040
String projectId = "your-project-id";
4141
String textToInspect =

dlp/src/main/java/dlp/snippets/DeIdentifyWithSimpleWordList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
public class DeIdentifyWithSimpleWordList {
3939

40-
public static void deIdentifyWithSimpleWordList() throws IOException {
40+
public static void main(String[] args) throws Exception {
4141
// TODO(developer): Replace these variables before running the sample.
4242
String projectId = "your-project-id";
4343
String textToDeIdentify = "Patient was seen in RM-YELLOW then transferred to rm green.";

dlp/src/main/java/dlp/snippets/InspectBigQueryTable.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848

4949
public class InspectBigQueryTable {
5050

51-
public static void inspectBigQueryTable()
52-
throws InterruptedException, ExecutionException, IOException {
51+
public static void main(String[] args) throws Exception {
5352
// TODO(developer): Replace these variables before running the sample.
5453
String projectId = "your-project-id";
5554
String bigQueryDatasetId = "your-bigquery-dataset-id";

dlp/src/main/java/dlp/snippets/InspectBigQueryTableWithSampling.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747

4848
public class InspectBigQueryTableWithSampling {
4949

50-
public static void inspectBigQueryTableWithSampling()
51-
throws InterruptedException, ExecutionException, IOException {
50+
public static void main(String[] args) throws Exception {
5251
// TODO(developer): Replace these variables before running the sample.
5352
String projectId = "your-project-id";
5453
String topicId = "your-pubsub-topic-id";

dlp/src/main/java/dlp/snippets/InspectDatastoreEntity.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949

5050
public class InspectDatastoreEntity {
5151

52-
public static void insepctDatastoreEntity()
53-
throws InterruptedException, ExecutionException, IOException {
52+
public static void main(String[] args) throws Exception {
5453
// TODO(developer): Replace these variables before running the sample.
5554
String projectId = "your-project-id";
5655
String datastoreNamespace = "your-datastore-namespace";

dlp/src/main/java/dlp/snippets/InspectGcsFile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
public class InspectGcsFile {
5050

51-
public static void inspectGcsFile() throws InterruptedException, ExecutionException, IOException {
51+
public static void main(String[] args) throws Exception {
5252
// TODO(developer): Replace these variables before running the sample.
5353
String projectId = "your-project-id";
5454
String gcsUri = "gs://" + "your-bucket-name" + "/path/to/your/file.txt";

dlp/src/main/java/dlp/snippets/InspectGcsFileWithSampling.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848

4949
public class InspectGcsFileWithSampling {
5050

51-
public static void inspectGcsFileWithSampling()
52-
throws InterruptedException, ExecutionException, IOException {
51+
public static void main(String[] args) throws Exception {
5352
// TODO(developer): Replace these variables before running the sample.
5453
String projectId = "your-project-id";
5554
String gcsUri = "gs://" + "your-bucket-name" + "/path/to/your/file.txt";

dlp/src/main/java/dlp/snippets/InspectImageFile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class InspectImageFile {
3838

39-
public static void inspectImageFile() throws IOException {
39+
public static void main(String[] args) throws Exception {
4040
// TODO(developer): Replace these variables before running the sample.
4141
String projectId = "your-project-id";
4242
String filePath = "path/to/image.png";

dlp/src/main/java/dlp/snippets/InspectPhoneNumber.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class InspectPhoneNumber {
3333

34-
public static void inspectString() throws IOException {
34+
public static void main(String[] args) throws Exception {
3535
// TODO(developer): Replace these variables before running the sample.
3636
String projectId = "your-project-id";
3737
String textToInspect = "My name is Gary and my email is gary@example.com";

dlp/src/main/java/dlp/snippets/InspectString.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
public class InspectString {
3737

38-
public static void inspectString() throws IOException {
38+
public static void main(String[] args) throws Exception {
3939
// TODO(developer): Replace these variables before running the sample.
4040
String projectId = "your-project-id";
4141
String textToInspect = "My name is Gary and my email is gary@example.com";

dlp/src/main/java/dlp/snippets/InspectStringCustomExcludingSubstring.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
public class InspectStringCustomExcludingSubstring {
4545

46-
public static void inspectStringCustomExcludingSubstring() throws IOException {
46+
public static void main(String[] args) throws Exception {
4747
// TODO(developer): Replace these variables before running the sample.
4848
String projectId = "your-project-id";
4949
String textToInspect = "Name: Doe, John. Name: Example, Jimmy";

dlp/src/main/java/dlp/snippets/InspectStringCustomHotword.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class InspectStringCustomHotword {
4242

43-
public static void inspectStringCustomHotword() throws IOException {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
String textToInspect = "patient name: John Doe";

dlp/src/main/java/dlp/snippets/InspectStringCustomOmitOverlap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
public class InspectStringCustomOmitOverlap {
4343

44-
public static void inspectStringCustomOmitOverlap() throws IOException {
44+
public static void main(String[] args) throws Exception {
4545
// TODO(developer): Replace these variables before running the sample.
4646
String projectId = "your-project-id";
4747
String textToInspect = "Name: Jane Doe. Name: Larry Page.";

dlp/src/main/java/dlp/snippets/InspectStringMultipleRules.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
public class InspectStringMultipleRules {
4646

47-
public static void inspectStringMultipleRules() throws IOException {
47+
public static void main(String[] args) throws Exception {
4848
// TODO(developer): Replace these variables before running the sample.
4949
String projectId = "your-project-id";
5050
String textToInspect = "patient: Jane Doe";

dlp/src/main/java/dlp/snippets/InspectStringOmitOverlap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class InspectStringOmitOverlap {
4242

43-
public static void inspectStringOmitOverlap() throws IOException {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
String textToInspect = "james@example.com";

dlp/src/main/java/dlp/snippets/InspectStringWithExclusionDict.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
public class InspectStringWithExclusionDict {
4444

45-
public static void inspectStringWithExclusionDict() throws IOException {
45+
public static void main(String[] args) throws Exception {
4646
// TODO(developer): Replace these variables before running the sample.
4747
String projectId = "your-project-id";
4848
String textToInspect = "Some email addresses: gary@example.com, example@example.com";

dlp/src/main/java/dlp/snippets/InspectStringWithExclusionDictSubstring.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
public class InspectStringWithExclusionDictSubstring {
4444

45-
public static void inspectStringWithExclusionDictSubstring() throws IOException {
45+
public static void main(String[] args) throws Exception {
4646
// TODO(developer): Replace these variables before running the sample.
4747
String projectId = "your-project-id";
4848
String textToInspect = "Some email addresses: gary@example.com, TEST@example.com";

dlp/src/main/java/dlp/snippets/InspectStringWithExclusionRegex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class InspectStringWithExclusionRegex {
4242

43-
public static void inspectStringWithExclusionRegex() throws IOException {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
String textToInspect = "Some email addresses: gary@example.com, bob@example.org";

dlp/src/main/java/dlp/snippets/InspectStringWithoutOverlap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
public class InspectStringWithoutOverlap {
4444

45-
public static void inspectStringWithoutOverlap() throws IOException {
45+
public static void main(String[] args) throws Exception {
4646
// TODO(developer): Replace these variables before running the sample.
4747
String projectId = "your-project-id";
4848
String textToInspect = "example.com is a domain, james@example.org is an email.";

dlp/src/main/java/dlp/snippets/InspectTable.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class InspectTable {
4242

43-
public static void inspectTable() {
43+
public static void main(String[] args) throws Exception {
4444
// TODO(developer): Replace these variables before running the sample.
4545
String projectId = "your-project-id";
4646
Table tableToInspect = Table.newBuilder()

dlp/src/main/java/dlp/snippets/InspectTextFile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class InspectTextFile {
3838

39-
public static void inspectTextFile() throws IOException {
39+
public static void main(String[] args) throws Exception {
4040
// TODO(developer): Replace these variables before running the sample.
4141
String projectId = "your-project-id";
4242
String filePath = "path/to/file.txt";

dlp/src/main/java/dlp/snippets/InspectWithCustomRegex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class InspectWithCustomRegex {
3838

39-
public static void inspectWithCustomRegex() throws IOException {
39+
public static void main(String[] args) throws Exception {
4040
// TODO(developer): Replace these variables before running the sample.
4141
String projectId = "your-project-id";
4242
String textToInspect = "Patients MRN 444-5-22222";

0 commit comments

Comments
 (0)