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


##########
extensions-contrib/druid-exact-cardinality/src/main/java/org/apache/druid/query/aggregation/exact/cardinality/bitmap64/RoaringBitmap64Counter.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.exact.cardinality.bitmap64;
+
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.nio.ByteBuffer;
+
+public class RoaringBitmap64Counter implements Bitmap64Counter
+{
+  private static Logger logger = new Logger(RoaringBitmap64Counter.class);
+
+  private Roaring64NavigableMap bitmap;
+
+  public RoaringBitmap64Counter()
+  {
+    this.bitmap = new Roaring64NavigableMap();
+  }
+
+  private RoaringBitmap64Counter(Roaring64NavigableMap bitmap)
+  {
+    this.bitmap = bitmap;
+  }
+
+  public static RoaringBitmap64Counter fromBytes(byte[] bytes)
+  {
+    ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes);
+    try {
+      DataInputStream in = new DataInputStream(byteIn);
+      Roaring64NavigableMap bitmap = new Roaring64NavigableMap();
+      bitmap.deserialize(in);
+      return new RoaringBitmap64Counter(bitmap);
+    }
+    catch (Exception e) {
+      logger.info(e.getMessage(), e);
+    }
+    return null;
+  }
+
+  @Override
+  public void add(long value)
+  {
+    bitmap.addLong(value);
+  }
+
+  @Override
+  public long getCardinality()
+  {
+    return bitmap.getLongCardinality();
+  }
+
+  @Override
+  public Bitmap64Counter fold(Bitmap64Counter rhs)
+  {
+    if (rhs != null) {
+      bitmap.or(((RoaringBitmap64Counter) rhs).bitmap);
+    }
+
+    return this;
+  }
+
+  @Override
+  public ByteBuffer toByteBuffer()
+  {
+    bitmap.runOptimize();
+    try {
+      final ByteArrayOutputStream out = new ByteArrayOutputStream();
+      bitmap.serialize(new DataOutputStream(out));
+      return ByteBuffer.wrap(out.toByteArray());
+    }
+    catch (Exception e) {
+      throw Throwables.propagate(e);

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



##########
extensions-contrib/druid-exact-cardinality/src/main/java/org/apache/druid/query/aggregation/exact/cardinality/bitmap64/Bitmap64ExactCardinalityObjectStrategy.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.exact.cardinality.bitmap64;
+
+import org.apache.druid.segment.data.ObjectStrategy;
+
+import javax.annotation.Nullable;
+import java.nio.ByteBuffer;
+
+public class Bitmap64ExactCardinalityObjectStrategy implements 
ObjectStrategy<Bitmap64Counter>
+{
+
+  static final Bitmap64ExactCardinalityObjectStrategy STRATEGY = new 
Bitmap64ExactCardinalityObjectStrategy();
+
+  @Override
+  public Class<? extends Bitmap64Counter> getClazz()
+  {
+    return RoaringBitmap64Counter.class;
+  }
+
+  @Nullable
+  @Override
+  public Bitmap64Counter fromByteBuffer(ByteBuffer buffer, int numBytes)
+  {
+    final ByteBuffer readOnlyBuffer = buffer.asReadOnlyBuffer();
+    readOnlyBuffer.limit(readOnlyBuffer.position() + numBytes);

Review Comment:
   ## User-controlled data in arithmetic expression
   
   This arithmetic expression depends on a [user-provided value](1), 
potentially causing an overflow.
   This arithmetic expression depends on a [user-provided value](2), 
potentially causing an overflow.
   This arithmetic expression depends on a [user-provided value](3), 
potentially causing an overflow.
   This arithmetic expression depends on a [user-provided value](4), 
potentially causing an overflow.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9194)



-- 
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