Skip to content

Commit

Permalink
[Refactor] Fix VirusTotal scanning
Browse files Browse the repository at this point in the history
Updated VirusTotal SSL certificates

Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Apr 4, 2024
1 parent 3c96616 commit 82c3509
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
signaturesView.setCardBackgroundColor(cardColor);
MaterialCardView missingLibsView = view.findViewById(R.id.missing_libs);
missingLibsView.setCardBackgroundColor(cardColor);
boolean isInternetEnabled = FeatureController.isInternetEnabled();
// VirusTotal
if (!isInternetEnabled || Prefs.VirusTotal.getApiKey() == null) {
if (!FeatureController.isVirusTotalEnabled() || Prefs.VirusTotal.getApiKey() == null) {
mVtContainerView.setVisibility(View.GONE);
view.findViewById(R.id.vt_disclaimer).setVisibility(View.GONE);
}
// Pithus
if (!isInternetEnabled) {
if (!FeatureController.isInternetEnabled()) {
pithusContainerView.setVisibility(View.GONE);
}
// Checksum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,24 @@ private void cacheFileIfRequired() {
@WorkerThread
private void generateApkChecksumsAndFetchScanReports() {
waitForFile();
Path file = Paths.getUnprivileged(mApkFile);
String pithusReportUrl = null;
try {
Path file = Paths.getUnprivileged(mApkFile);
Pair<String, String>[] digests = DigestUtils.getDigests(file);
mApkChecksumsLiveData.postValue(digests);
if (FeatureController.isInternetEnabled()) {
String md5 = digests[0].second;
String sha256 = digests[2].second;
pithusReportUrl = ExUtils.exceptionAsNull(() -> Pithus.resolveReport(sha256));
if (mVt == null) return;
mVt.fetchReportsOrScan(file, md5, this);
}
} catch (IOException e) {
e.printStackTrace();
mApkChecksumsLiveData.postValue(null);
mVtFileReportLiveData.postValue(null);
Pair<String, String>[] digests = ExUtils.exceptionAsNull(() -> DigestUtils.getDigests(file));
mApkChecksumsLiveData.postValue(digests);
if (digests != null && FeatureController.isInternetEnabled()) {
String sha256 = digests[2].second;
pithusReportUrl = ExUtils.exceptionAsNull(() -> Pithus.resolveReport(sha256));
}
mPithusReportLiveData.postValue(pithusReportUrl);
if (mVt != null && digests != null && FeatureController.isVirusTotalEnabled()) {
String md5 = digests[0].second;
try {
mVt.fetchReportsOrScan(file, md5, this);
} catch (IOException e) {
e.printStackTrace();
mVtFileReportLiveData.postValue(null);
}
} else mVtFileReportLiveData.postValue(null);
}

private void loadApkVerifierResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface FullScanResponseInterface {
@Nullable
public static VirusTotal getInstance() {
String apiKey = Prefs.VirusTotal.getApiKey();
if (FeatureController.isInternetEnabled() && apiKey != null) {
if (FeatureController.isVirusTotalEnabled() && apiKey != null) {
return new VirusTotal(apiKey);
}
return null;
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<base-config cleartextTrafficPermitted="false" />
<domain-config>
<domain includeSubdomains="true">www.virustotal.com</domain>
<pin-set expiration="2031-04-13">
<pin-set expiration="2038-01-15">
<!-- DigiCert Global Root CA -->
<pin digest="SHA-256">r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=</pin>

<!-- DigiCert TLS RSA SHA256 2020 CA1 -->
<pin digest="SHA-256">RQeZkB42znUfsDIIFWIRiYEcKl7nHwNFwWCrnMMJbVc=</pin>
<!-- DigiCert Global Root G2 -->
<pin digest="SHA-256">i7WTqTvh0OioIruIfFR4kMPnBqrS2rdiVPl/s2uC/CY=</pin>
</pin-set>
</domain-config>
<domain-config>
<domain includeSubdomains="true">beta.pithus.org</domain>
<pin-set expiration="2024-10-01">
<pin-set expiration="2035-01-03">
<!--
Resources:
https://letsencrypt.org/certificates/
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/xml/preferences_virus_total.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
app:persistent="false"
app:iconSpaceReserved="false" />

<io.github.muntashirakon.preference.DefaultAlertPreference
<io.github.muntashirakon.preference.WarningAlertPreference
app:key="info_no_internet"
app:icon="@drawable/ic_caution"
app:iconSpaceReserved="false"
app:selectable="false"
app:summary="@string/pref_use_vt_no_internet" />
Expand Down

0 comments on commit 82c3509

Please sign in to comment.