github-advanced-security[bot] commented on code in PR #20327:
URL: https://github.com/apache/druid/pull/20327#discussion_r3986617208


##########
extensions-core/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureDataSegmentKillerTest.java:
##########
@@ -90,6 +91,20 @@
       1
   );
 
+  // pushed with druid.storage.zip=false, so blobPath is the directory holding 
the segment files
+  private static final String UNZIPPED_BLOB_PATH = 
"test/2015-04-12T00:00:00.000Z_2015-04-13T00:00:00.000Z/1/0/";
+  private static final DataSegment UNZIPPED_DATA_SEGMENT = new DataSegment(
+      "test",
+      Intervals.of("2015-04-12/2015-04-13"),
+      "1",
+      ImmutableMap.of("containerName", CONTAINER_NAME, "blobPath", 
UNZIPPED_BLOB_PATH),
+      null,
+      null,
+      new LinearShardSpec(0),
+      0,
+      1
+  );

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.DataSegment](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11952)



##########
server/src/test/java/org/apache/druid/guice/LocalDataStorageDruidModuleTest.java:
##########
@@ -47,6 +59,59 @@
     );
   }
 
+  /**
+   * {@code druid.storage.zip} is bound by this module for every deep storage 
implementation to read, so check that it
+   * actually reaches the pusher the module provisions, rather than only that 
it parses.
+   */
+  @Test
+  public void testDataSegmentPusherHonorsStorageZip(@TempDir File tempDir) 
throws IOException
+  {
+    Assertions.assertTrue(new File(pushSegment(tempDir, "true"), 
"index.zip").isFile());
+  }
+
+  @Test
+  public void testDataSegmentPusherDefaultsToUnzipped(@TempDir File tempDir) 
throws IOException
+  {
+    // local deep storage writes a directory of files when the property is 
unset, which is the default the tri-state
+    // DeepStorageSegmentConfig exists to preserve
+    Assertions.assertTrue(new File(pushSegment(tempDir, null), 
"index").isDirectory());
+  }
+
+  /**
+   * Pushes a one-file segment through a {@link DataSegmentPusher} provisioned 
by this module, and returns the
+   * directory it was pushed to.
+   */
+  private static File pushSegment(File tempDir, @Nullable String zip) throws 
IOException
+  {
+    final File storageDir = new File(tempDir, "deepStorage");
+    final File segmentDir = new File(tempDir, "segment");
+    FileUtils.mkdirp(segmentDir);
+    Files.asByteSink(new File(segmentDir, 
"version.bin")).write(Ints.toByteArray(0x9));
+
+    final Injector injector = createInjector();
+    // JsonConfigProvider reads these lazily, on the first getInstance below
+    final Properties properties = injector.getInstance(Properties.class);
+    properties.setProperty("druid.storage.storageDirectory", 
storageDir.getAbsolutePath());
+    if (zip != null) {
+      properties.setProperty("druid.storage.zip", zip);
+    }
+
+    final DataSegmentPusher pusher = 
injector.getInstance(DataSegmentPusher.class);
+    final DataSegment segment = new DataSegment(
+        "ds",
+        Intervals.utc(0, 1),
+        "v1",
+        null,
+        null,
+        null,
+        NoneShardSpec.instance(),
+        null,
+        0
+    );

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.DataSegment](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11953)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to