Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: code cleanup #2519

Draft
wants to merge 68 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6bb349d
fix: make those fields final
brenoepics Jun 9, 2024
da61d30
refactor: make getGoodsLimit one liner
brenoepics Jun 9, 2024
ef58ab3
refactor: replace `size() == 0` with isEmpty()
brenoepics Jun 9, 2024
c3eafba
refactor: remove unnecessary toString call
brenoepics Jun 9, 2024
029ef82
refactor: remove unnecessary semicolons
brenoepics Jun 9, 2024
9fa0f2b
refactor: unwrap redundant code block
brenoepics Jun 9, 2024
7d3abb0
refactor: this can also be final
brenoepics Jun 9, 2024
ca6ddfd
refactor: replace protected with private for final class
brenoepics Jun 9, 2024
0161b4d
refactor: replace protected with private for final class
brenoepics Jun 9, 2024
427a1cf
fix: variable is assigned to itself
brenoepics Jun 9, 2024
9c946e9
chore: remove unused import
brenoepics Jun 9, 2024
8c35c89
refactor: replace Collections.sort with list.sort
brenoepics Jun 9, 2024
870085f
refactor: replace lambda with method reference
brenoepics Jun 9, 2024
3119e0f
refactor: replace lambda with method reference
brenoepics Jun 9, 2024
c7119aa
refactor: simplify map operations
brenoepics Jun 9, 2024
fcd4093
refactor: replace statement with expression lambda
brenoepics Jun 9, 2024
b5d0afd
refactor: we don't need explicit types here
brenoepics Jun 9, 2024
bb82e21
refactor: replace for loop with enhanced loop
brenoepics Jun 9, 2024
6d669bd
refactor: Integer.ParseInt is more appropriate here
brenoepics Jun 9, 2024
7db8b6f
refactor: Integer.ParseInt is more appropriate here
brenoepics Jun 9, 2024
c9b42a6
refactor: replace switch with enhanced switch
brenoepics Jun 9, 2024
77e2462
refactor: fix javadoc issues
brenoepics Jun 9, 2024
6e7418a
refactor: replace concatenation log with parameterized
brenoepics Jun 9, 2024
d5ad077
fix: integer division in floating point
brenoepics Jun 9, 2024
6e3b3b2
refactor: implicit cast from double to float may be lossy
brenoepics Jun 9, 2024
4f1ad7b
perf: Call to 'asList()' with only one argument
brenoepics Jun 9, 2024
e4123f4
perf: class initializer may be static
brenoepics Jun 9, 2024
b773529
perf: `count > 0` can be anyMatch
brenoepics Jun 9, 2024
33d5c52
perf: `findAny().isPresent()` is cleaner here
brenoepics Jun 9, 2024
1424405
perf: fix redundant addAll
brenoepics Jun 9, 2024
1e2ccc9
perf: we can chain append here
brenoepics Jun 9, 2024
aeadf6b
perf: equals "" can be isEmpty here
brenoepics Jun 9, 2024
7ee644c
perf: add Serial annotation here
brenoepics Jun 9, 2024
8f4120f
refactor(lombok): add Getter where possible
brenoepics Jun 9, 2024
dd9f59f
refactor(lombok): add Setter where possible
brenoepics Jun 9, 2024
4b03304
perf: this is just Math.min
brenoepics Jun 9, 2024
f01da54
perf: size cannot be negative
brenoepics Jun 9, 2024
8f8a6a7
perf: simplify optional chain
brenoepics Jun 9, 2024
85ca877
perf: remove redundant collection operation
brenoepics Jun 9, 2024
3d00abc
perf: we can just equalsIgnoreCase
brenoepics Jun 9, 2024
45bf5ed
perf: stream api can be simplified here
brenoepics Jun 9, 2024
809009f
refactor: null check is not necessary, we have instanceof
brenoepics Jun 9, 2024
db28038
chore: fix codestyle indentation
brenoepics Jun 9, 2024
3b68645
refactor: number comparison
brenoepics Jun 9, 2024
d4ce7aa
refactor: fix nullable params
brenoepics Jun 9, 2024
8c53f2b
Format code [skip actions]
github-actions[bot] Jun 9, 2024
bfc2c7c
refactor: fix lombok
brenoepics Jun 9, 2024
2bb2da4
Format code [skip actions]
github-actions[bot] Jun 9, 2024
dbb4f85
ci: bump actions
brenoepics Jun 9, 2024
c313939
Merge branch 'development' of https://github.com/brenoepics/Grasscutt…
brenoepics Jun 9, 2024
1234d18
ci: Create dependabot.yml
brenoepics Jun 9, 2024
62d53f3
chore(deps): bump com.google.protobuf:protoc from 3.18.1 to 4.27.1
dependabot[bot] Jun 9, 2024
52b7ca6
chore(deps): bump com.fasterxml.jackson:jackson-bom
dependabot[bot] Jun 9, 2024
bbec09d
chore(deps): bump org.jline:jline-terminal-jna from 3.21.0 to 3.26.1
dependabot[bot] Jun 9, 2024
ff2aeac
chore(deps): bump org.junit.jupiter:junit-jupiter-engine
dependabot[bot] Jun 9, 2024
63fbe66
security: add secure mode and padding scheme
brenoepics Jun 9, 2024
75d8ed0
Merge branch 'development' of https://github.com/brenoepics/Grasscutt…
brenoepics Jun 9, 2024
0736956
Format code [skip actions]
github-actions[bot] Jun 9, 2024
fa283d8
Merge pull request #1 from brenoepics/dependabot/gradle/com.google.pr…
brenoepics Jun 9, 2024
22c7f3c
Merge pull request #2 from brenoepics/dependabot/gradle/com.fasterxml…
brenoepics Jun 9, 2024
a05d6cd
Merge pull request #3 from brenoepics/dependabot/gradle/org.jline-jli…
brenoepics Jun 9, 2024
cd48328
Merge pull request #4 from brenoepics/dependabot/gradle/org.junit.jup…
brenoepics Jun 9, 2024
011549f
chore(deps): bump org.java-websocket:Java-WebSocket from 1.5.2 to 1.5.6
dependabot[bot] Jun 10, 2024
0819435
chore(deps): bump ch.qos.logback:logback-core from 1.4.7 to 1.5.6
dependabot[bot] Jun 10, 2024
a0922ff
Merge pull request #9 from brenoepics/dependabot/gradle/ch.qos.logbac…
brenoepics Jun 10, 2024
c77aa52
Merge pull request #7 from brenoepics/dependabot/gradle/org.java-webs…
brenoepics Jun 10, 2024
ab5824b
chore(deps): bump org.slf4j:slf4j-api from 2.0.7 to 2.0.13
dependabot[bot] Jun 10, 2024
0e7e165
Merge pull request #8 from brenoepics/dependabot/gradle/org.slf4j-slf…
brenoepics Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public LoginResultJson authenticate(AuthenticationRequest request) {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
RSAPrivateKey private_key = (RSAPrivateKey) keyFactory.generatePrivate(keySpec);

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");

cipher.init(Cipher.DECRYPT_MODE, private_key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void handle(GameSession session, byte[] header, byte[] payload) throws Ex
if (req.getKeyId() > 0) {
var encryptSeed = session.getEncryptSeed();
try {
var cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
var cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify that this is compatible with the client or just apply suggestions from sonarcloud?
Because this has a high chance of breaking the ps. Same for the other crypto algorithm changes.

cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY);

var clientSeedEncrypted = Utils.base64Decode(req.getClientRandKey());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/emu/grasscutter/utils/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.*;
import java.util.regex.Pattern;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;

public final class Crypto {

Expand Down Expand Up @@ -100,8 +101,8 @@ public static QueryCurRegionRspJson encryptAndSignRegionData(byte[] regionInfo,
if (key_id == null) {
throw new Exception("Key ID was not set");
}
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, EncryptionKeys.get(Integer.valueOf(key_id)));

// Encrypt regionInfo in chunks
Expand Down