Conversation
|
@tomholub I can see some Snyk tests failed, however I can't see what exactly. Please check. |
|
@IvanPizhenko Sorry to answer a question not directed at me, but I checked on Snyk and it appears this PR introduces a vulnerable dependency. Specifically, flowcrypt-android/FlowCrypt/build.gradle Line 459 in 0c43360 Depends on a version of The codebase on https://github.com/OWASP/java-html-sanitizer has actually updated to a non-vulnerable Guava version (here: OWASP/java-html-sanitizer@ad287c3), but there hasn't been a release in quite some time which is why we're having this problem. The actual vulnerability is that files used in the temp dir created via Guava's Consequently, I've told Snyk to skip this check and mark it as passed. |
|
Thank you Alex for looking into this 👍 |
tomholub
left a comment
There was a problem hiding this comment.
Thanks! So far only reviewed the tests. Sorry if the answer is obvious.
| } | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Approximately 14 test files (.txt) were added below, but this test is using only a handful of them. Where are they being loaded and used?
There was a problem hiding this comment.
All these files should be used in the tests here.
There was a problem hiding this comment.
Looks like mime-email-*.txt are not used. Will remove them
DenBond7
left a comment
There was a problem hiding this comment.
@IvanPizhenko Please look at my comments. I didn't try your realization yet but it will be a start point of the final migration. On the current stage it's hard to say what is good or not good.
FlowCrypt/src/main/java/com/flowcrypt/email/core/msg/MimeUtils.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/extensions/java/io/InputStreamExt.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/extensions/kotlin/StringExt.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/api/retrofit/response/model/node/MsgBlock.kt
Show resolved
Hide resolved
| val type: PgpDecrypt.DecryptionErrorType, | ||
| val message: String, | ||
| val cause: Throwable? = null | ||
| ) | ||
| ) : Parcelable { |
There was a problem hiding this comment.
unfortunately, we can't use Throwable in Parcelable implementation in data classes. We can't compare Throwable instance here. That's why some of JUnit tests were failed.
FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
Outdated
Show resolved
Hide resolved
tomholub
left a comment
There was a problem hiding this comment.
This PR is pretty massive 👀 which reflects the issue is a complicated one. It looks good. On my end, I mainly want to make sure that all provided test cases are indeed tested (see earlier question) and if not, that we file an issue to test all soon.
| val firstChars = msg.copyOfRange(0, msg.size.coerceAtMost(1000)) | ||
| .toString(StandardCharsets.US_ASCII) | ||
| .toLowerCase(Locale.ROOT) |
There was a problem hiding this comment.
I wonder if the conversion to String can fail with an exception if we give it arbitrary bytes that are non-ascii. If it can fail by throwing, we should catch the error and return false.
There was a problem hiding this comment.
Did the small test:
import java.nio.charset.StandardCharsets
import java.util.Locale
fun main() {
val a = ByteArray(256)
for (i in 0..255) a[i] = i.toByte()
val s = a.toString(StandardCharsets.US_ASCII).toLowerCase(Locale.ROOT)
println(s)
}Works for all source byte values.
FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
Outdated
Show resolved
Hide resolved
As long as it passes the supplied test cases, then it's well good enough. Of course, some adjustments will be needed once you start integrating, but if we confirm that supplied test cases pass the way they do on TypeScript code (and code style stuff gets adjusted) then this is perfectly fine for merging even if we didn't try to integrate it yet. |
Thanks Alex! |
|
@IvanPizhenko I've added some changes to fix tests |
tomholub
left a comment
There was a problem hiding this comment.
I've reviewed the changes and they look good. I'll still give it a review regarding the test cases, then can merge.
| @@ -0,0 +1,14 @@ | |||
| -----BEGIN PGP MESSAGE----- | |||
There was a problem hiding this comment.
This file is not used anywhere that I can find
| @@ -0,0 +1,36 @@ | |||
| -----BEGIN PGP MESSAGE----- | |||
There was a problem hiding this comment.
This file is not used anywhere that I can find
This PR introduces native Kotlin-base processing of the complex email messages
close #1057
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):