Skip to content

Commit

Permalink
Glide library detection rule
Browse files Browse the repository at this point in the history
  • Loading branch information
stoletheminerals committed Nov 21, 2024
1 parent 19fa03f commit bafaec2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions assets/semgrep_rules/client/glide-library.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ruleid: glide-library
import com.bumptech.glide.load.DataSource;

if (mBraveNewsController != null) {
mBraveNewsController.getImageData(adImageUrl, imageData -> {
if (imageData != null) {
Bitmap decodedByte =
BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
// ruleid: glide-library
Glide.with(mActivity)
.asBitmap()
.load(decodedByte)
.fitCenter()
.priority(Priority.IMMEDIATE)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource,
@Nullable Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {}
});
imageView.setClipToOutline(true);
}
});
}
17 changes: 17 additions & 0 deletions assets/semgrep_rules/client/glide-library.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
- id: glide-library
metadata:
author: Artem Chaikin
references:
- https://github.com/brave/reviews/issues/1391
source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/glide-library.yaml
assignees: |
stoletheminerals
bridiver
message: "The Glide image loading library is not yet approved, new usages should not be implemented until the security team has given their approval."
languages: [java]
severity: WARNING
patterns:
- pattern-either:
- pattern: "import com.bumptech.glide"
- pattern: "Glide.with(...)"

0 comments on commit bafaec2

Please sign in to comment.