Skip to content

Commit 03decb0

Browse files
committed
Implement random salt generation for credential encryption and add Qodana configuration
1 parent 8df58e5 commit 03decb0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

qodana.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
version: "1.0"
6+
7+
#Specify inspection profile for code analysis
8+
profile:
9+
name: qodana.starter
10+
11+
#Enable inspections
12+
#include:
13+
# - name: <SomeEnabledInspectionId>
14+
15+
#Disable inspections
16+
#exclude:
17+
# - name: <SomeDisabledInspectionId>
18+
# paths:
19+
# - <path/where/not/run/inspection>
20+
21+
projectJDK: "24" #(Applied in CI/CD pipeline)
22+
23+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
24+
#bootstrap: sh ./prepare-qodana.sh
25+
26+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
27+
#plugins:
28+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
29+
30+
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
31+
linter: jetbrains/qodana-jvm:2025.1

src/main/java/io/github/ozkanpakdil/swaggerific/security/CredentialEncryption.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
public class CredentialEncryption {
1616
private static final String ALGORITHM = "AES/GCM/NoPadding";
1717
private static final String KEY_ALGORITHM = "AES";
18-
private static final byte[] SALT = "SwaggerificSalt".getBytes(StandardCharsets.UTF_8);
1918
private static final int GCM_IV_LENGTH = 12;
2019
private static final int GCM_TAG_LENGTH = 128;
2120
private static final SecretKey secretKey;
@@ -27,6 +26,8 @@ public class CredentialEncryption {
2726
System.getProperty("user.home");
2827

2928
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
29+
byte[] SALT;
30+
new SecureRandom().nextBytes(SALT = new byte[16]); // Generate a random salt
3031
KeySpec spec = new PBEKeySpec(systemSpecific.toCharArray(), SALT, 65536, 256);
3132
SecretKey tmp = factory.generateSecret(spec);
3233
secretKey = new SecretKeySpec(tmp.getEncoded(), KEY_ALGORITHM);

0 commit comments

Comments
 (0)