From 97227b7fc003ac27af25334e5e6187d3a8699ab9 Mon Sep 17 00:00:00 2001 From: gabriel-logan Date: Thu, 11 Jul 2024 13:38:58 -0300 Subject: [PATCH] feat: Add FileValidator class for multiform validation --- .gitignore | 1 + .../1035b95fde851fd8381dabb4da89dd79908aed9b | 10 +- .../3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d | 4 + .../6e481a8cc098ad8ab7f553fbd33042be7454e52a | 0 .../aa5999cb67ff93d7fa1f135c6ce35751a7f50782 | 3 + .../d90a638069474de771e722f81c6e4f61b75eb1c4 | 0 .../df99130c3df382b199c34a94824d11e25467ed68 | 4 + .idea/sonarlint/issuestore/index.pb | 12 ++- .../3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d | 0 .../6e481a8cc098ad8ab7f553fbd33042be7454e52a | 0 .../aa5999cb67ff93d7fa1f135c6ce35751a7f50782 | 0 .../d90a638069474de771e722f81c6e4f61b75eb1c4 | 0 .../df99130c3df382b199c34a94824d11e25467ed68 | 0 .idea/sonarlint/securityhotspotstore/index.pb | 12 ++- .idea/workspace.xml | 85 ++++++--------- .../multiform_validator/FileValidator.java | 98 ++++++++++++++++++ src/test/java/FileValidatorTest.java | 50 +++++++++ .../assets/isValidAudio/invalid/invalid.mp3 | 1 + .../assets/isValidAudio/invalid/invalid.wav | 1 + .../java/assets/isValidAudio/valid/valid.mp3 | Bin 0 -> 24442 bytes .../java/assets/isValidAudio/valid/valid.wav | Bin 0 -> 271588 bytes .../assets/isValidImage/invalid/invalid.avif | 1 + .../assets/isValidImage/invalid/invalid.gif | 1 + .../assets/isValidImage/invalid/invalid.ico | 1 + .../assets/isValidImage/invalid/invalid.jpg | 1 + .../assets/isValidImage/invalid/invalid.png | 1 + .../assets/isValidImage/invalid/invalid.svg | 1 + .../assets/isValidImage/invalid/invalid.webp | 1 + .../java/assets/isValidImage/valid/valid.avif | Bin 0 -> 4259 bytes .../java/assets/isValidImage/valid/valid.gif | Bin 0 -> 1154388 bytes .../java/assets/isValidImage/valid/valid.ico | Bin 0 -> 67646 bytes .../java/assets/isValidImage/valid/valid.jpg | Bin 0 -> 96239 bytes .../java/assets/isValidImage/valid/valid.png | Bin 0 -> 2096209 bytes .../java/assets/isValidImage/valid/valid.svg | 1 + .../java/assets/isValidImage/valid/valid.webp | Bin 0 -> 1888 bytes .../java/assets/isValidImage/valid/valid2.png | Bin 0 -> 3219 bytes src/test/java/assets/isValidPdf/invalid.pdf | Bin 0 -> 619 bytes src/test/java/assets/isValidPdf/valid.pdf | Bin 0 -> 54752 bytes src/test/java/assets/isValidTxt/invalid.txt | Bin 0 -> 54752 bytes src/test/java/assets/isValidTxt/valid.txt | 1 + .../assets/isValidVideo/invalid/invalid.mkv | 1 + .../assets/isValidVideo/invalid/invalid.mov | 1 + .../assets/isValidVideo/invalid/invalid.mp4 | 1 + .../java/assets/isValidVideo/valid/valid.mkv | Bin 0 -> 67572 bytes .../java/assets/isValidVideo/valid/valid.mov | Bin 0 -> 68765 bytes .../java/assets/isValidVideo/valid/valid.mp4 | Bin 0 -> 184598 bytes 46 files changed, 234 insertions(+), 59 deletions(-) create mode 100644 .idea/sonarlint/issuestore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d create mode 100644 .idea/sonarlint/issuestore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a create mode 100644 .idea/sonarlint/issuestore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 create mode 100644 .idea/sonarlint/issuestore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 create mode 100644 .idea/sonarlint/issuestore/d/f/df99130c3df382b199c34a94824d11e25467ed68 create mode 100644 .idea/sonarlint/securityhotspotstore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d create mode 100644 .idea/sonarlint/securityhotspotstore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a create mode 100644 .idea/sonarlint/securityhotspotstore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 create mode 100644 .idea/sonarlint/securityhotspotstore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 create mode 100644 .idea/sonarlint/securityhotspotstore/d/f/df99130c3df382b199c34a94824d11e25467ed68 create mode 100644 src/main/java/io/github/multiform_validator/FileValidator.java create mode 100644 src/test/java/FileValidatorTest.java create mode 100644 src/test/java/assets/isValidAudio/invalid/invalid.mp3 create mode 100644 src/test/java/assets/isValidAudio/invalid/invalid.wav create mode 100644 src/test/java/assets/isValidAudio/valid/valid.mp3 create mode 100644 src/test/java/assets/isValidAudio/valid/valid.wav create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.avif create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.gif create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.ico create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.jpg create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.png create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.svg create mode 100644 src/test/java/assets/isValidImage/invalid/invalid.webp create mode 100644 src/test/java/assets/isValidImage/valid/valid.avif create mode 100644 src/test/java/assets/isValidImage/valid/valid.gif create mode 100644 src/test/java/assets/isValidImage/valid/valid.ico create mode 100644 src/test/java/assets/isValidImage/valid/valid.jpg create mode 100644 src/test/java/assets/isValidImage/valid/valid.png create mode 100644 src/test/java/assets/isValidImage/valid/valid.svg create mode 100644 src/test/java/assets/isValidImage/valid/valid.webp create mode 100644 src/test/java/assets/isValidImage/valid/valid2.png create mode 100644 src/test/java/assets/isValidPdf/invalid.pdf create mode 100644 src/test/java/assets/isValidPdf/valid.pdf create mode 100644 src/test/java/assets/isValidTxt/invalid.txt create mode 100644 src/test/java/assets/isValidTxt/valid.txt create mode 100644 src/test/java/assets/isValidVideo/invalid/invalid.mkv create mode 100644 src/test/java/assets/isValidVideo/invalid/invalid.mov create mode 100644 src/test/java/assets/isValidVideo/invalid/invalid.mp4 create mode 100644 src/test/java/assets/isValidVideo/valid/valid.mkv create mode 100644 src/test/java/assets/isValidVideo/valid/valid.mov create mode 100644 src/test/java/assets/isValidVideo/valid/valid.mp4 diff --git a/.gitignore b/.gitignore index 38105ec..bf2bf7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Compiled class file *.class +/target # Log file *.log diff --git a/.idea/sonarlint/issuestore/1/0/1035b95fde851fd8381dabb4da89dd79908aed9b b/.idea/sonarlint/issuestore/1/0/1035b95fde851fd8381dabb4da89dd79908aed9b index bb55dd9..2763d12 100644 --- a/.idea/sonarlint/issuestore/1/0/1035b95fde851fd8381dabb4da89dd79908aed9b +++ b/.idea/sonarlint/issuestore/1/0/1035b95fde851fd8381dabb4da89dd79908aed9b @@ -1,11 +1,11 @@ ˜ -java:S1104#"UMake maxLength a static final constant or non-public and provide accessors if needed.(Ö­™č8ā˜ō“Š2J$27ac01a5-96ab-4818-a760-026487bb9b40 +java:S1104#"UMake maxLength a static final constant or non-public and provide accessors if needed.(Ö­™č8ā˜ō“Š2J$51dd86c5-3b5c-4844-beb9-246401324f0f – -java:S1104$"SMake country a static final constant or non-public and provide accessors if needed.(­ŽžĮ8á˜ō“Š2J$3fb1893c-13d9-4d09-90c5-a0c869f746d3 +java:S1104$"SMake country a static final constant or non-public and provide accessors if needed.(­ŽžĮ8á˜ō“Š2J$bc4a787c-439b-4d0f-ac25-83044af78fbc   -java:S1104%"XMake validDomains a static final constant or non-public and provide accessors if needed.(Äƙ‹ú˙˙˙˙8á˜ō“Š2J$05cf2b67-0674-493d-bd03-5b29e0e813fa +java:S1104%"XMake validDomains a static final constant or non-public and provide accessors if needed.(Äƙ‹ú˙˙˙˙8á˜ō“Š2J$bb9e992e-2dbf-4a09-a65d-2adb7c39d0b9 Ÿ -java:S1104&"\Make validDomainsList a static final constant or non-public and provide accessors if needed.(đÎđ™8á˜ō“Š2J$cb37d11e-220f-4a94-bb35-25b03b5273b8 +java:S1104&"\Make validDomainsList a static final constant or non-public and provide accessors if needed.(đÎđ™8á˜ō“Š2J$fc283562-d393-432e-b94d-5d49399c6905 š -java:S3776?"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(–åÕ˛ū˙˙˙˙8é™ō“Š2J$a80b18b5-e2ba-445d-a20e-b5782b176304 \ No newline at end of file +java:S3776?"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(–åÕ˛ū˙˙˙˙8é™ō“Š2J$7e173afa-107a-4265-b429-cbd6598bf5dd \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d b/.idea/sonarlint/issuestore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d new file mode 100644 index 0000000..e9c3728 --- /dev/null +++ b/.idea/sonarlint/issuestore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d @@ -0,0 +1,4 @@ + +š java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(Ū蒙˙˙˙˙˙J$7dedef73-8806-4af8-bf45-f6746dcdc5e0 +Š +java:S2094"BRemove this empty class, write its code or make it an "interface".(ŧũ§˙˙˙˙˙8áĻŒ”Š2J$422164ea-d1eb-48dc-8775-e971f816c441 \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a b/.idea/sonarlint/issuestore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 b/.idea/sonarlint/issuestore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 new file mode 100644 index 0000000..ed259c3 --- /dev/null +++ b/.idea/sonarlint/issuestore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 @@ -0,0 +1,3 @@ + +Š +java:S2094"BRemove this empty class, write its code or make it an "interface".(ŧũ§˙˙˙˙˙8áĻŒ”Š2J$c7bb9038-4984-408c-bba2-ffbb68ecc32f \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 b/.idea/sonarlint/issuestore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/d/f/df99130c3df382b199c34a94824d11e25467ed68 b/.idea/sonarlint/issuestore/d/f/df99130c3df382b199c34a94824d11e25467ed68 new file mode 100644 index 0000000..cf07c17 --- /dev/null +++ b/.idea/sonarlint/issuestore/d/f/df99130c3df382b199c34a94824d11e25467ed68 @@ -0,0 +1,4 @@ + +” java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(…ƇFJ$dd66f2c0-5b13-4aa2-bd78-dcdc85a858bd +d +java:S2094"BRemove this empty class, write its code or make it an "interface".(ŧũ§˙˙˙˙˙8áĻŒ”Š2 \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb index 73292bb..cdf02bc 100644 --- a/.idea/sonarlint/issuestore/index.pb +++ b/.idea/sonarlint/issuestore/index.pb @@ -34,4 +34,14 @@ Dsrc/main/java/io/github/multiform_validator/CreditCardValidator.java,b\4\b472d S #.github/workflows/java-pr-check.yml,6\d\6d7e0794b4bcc592eaba286aa7557da83ba765a5 m -=src/main/java/io/github/multiform_validator/CpfValidator.java,b\4\b4a2aa78fccd481c2a54c1b1f301c1651829b98c \ No newline at end of file +=src/main/java/io/github/multiform_validator/CpfValidator.java,b\4\b4a2aa78fccd481c2a54c1b1f301c1651829b98c +n +>src/main/java/io/github/multiform_validator/FileValidator.java,d\9\d90a638069474de771e722f81c6e4f61b75eb1c4 +| +Lsrc/main/java/io/github/multiform_validator/FileValidator/ValidateImage.java,d\f\df99130c3df382b199c34a94824d11e25467ed68 +t +Dsrc/main/java/io/github/multiform_validator/Other/ValidateImage.java,3\c\3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d +t +Dsrc/main/java/io/github/multiform_validator/other/ValidateImage.java,a\a\aa5999cb67ff93d7fa1f135c6ce35751a7f50782 +T +$src/test/java/FileValidatorTest.java,6\e\6e481a8cc098ad8ab7f553fbd33042be7454e52a \ No newline at end of file diff --git a/.idea/sonarlint/securityhotspotstore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d b/.idea/sonarlint/securityhotspotstore/3/c/3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/securityhotspotstore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a b/.idea/sonarlint/securityhotspotstore/6/e/6e481a8cc098ad8ab7f553fbd33042be7454e52a new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/securityhotspotstore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 b/.idea/sonarlint/securityhotspotstore/a/a/aa5999cb67ff93d7fa1f135c6ce35751a7f50782 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/securityhotspotstore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 b/.idea/sonarlint/securityhotspotstore/d/9/d90a638069474de771e722f81c6e4f61b75eb1c4 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/securityhotspotstore/d/f/df99130c3df382b199c34a94824d11e25467ed68 b/.idea/sonarlint/securityhotspotstore/d/f/df99130c3df382b199c34a94824d11e25467ed68 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb index 73292bb..cdf02bc 100644 --- a/.idea/sonarlint/securityhotspotstore/index.pb +++ b/.idea/sonarlint/securityhotspotstore/index.pb @@ -34,4 +34,14 @@ Dsrc/main/java/io/github/multiform_validator/CreditCardValidator.java,b\4\b472d S #.github/workflows/java-pr-check.yml,6\d\6d7e0794b4bcc592eaba286aa7557da83ba765a5 m -=src/main/java/io/github/multiform_validator/CpfValidator.java,b\4\b4a2aa78fccd481c2a54c1b1f301c1651829b98c \ No newline at end of file +=src/main/java/io/github/multiform_validator/CpfValidator.java,b\4\b4a2aa78fccd481c2a54c1b1f301c1651829b98c +n +>src/main/java/io/github/multiform_validator/FileValidator.java,d\9\d90a638069474de771e722f81c6e4f61b75eb1c4 +| +Lsrc/main/java/io/github/multiform_validator/FileValidator/ValidateImage.java,d\f\df99130c3df382b199c34a94824d11e25467ed68 +t +Dsrc/main/java/io/github/multiform_validator/Other/ValidateImage.java,3\c\3c8842d6f65bc0f21cf2bfc030702ffe7e82d70d +t +Dsrc/main/java/io/github/multiform_validator/other/ValidateImage.java,a\a\aa5999cb67ff93d7fa1f135c6ce35751a7f50782 +T +$src/test/java/FileValidatorTest.java,6\e\6e481a8cc098ad8ab7f553fbd33042be7454e52a \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7b727eb..2f7b29b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,32 +5,12 @@ + + - - - - - - - - - - - - - - - - - - - - - - - { - "keyToString": { - "Application.Main.executor": "Run", - "Application.io.github.gabriel_logan.multiform_validator.Main.executor": "Run", - "Application.io.github.multiform_validator.Main.executor": "Run", - "JUnit.AsciiTest.executor": "Run", - "JUnit.CnpjValidatorTest.executor": "Run", - "JUnit.CpfValidatorTest.executor": "Run", - "JUnit.CpfValidatorTest.testNullCpf.executor": "Run", - "JUnit.CreditCardValidatorTest.executor": "Run", - "JUnit.CreditCardValidatorTest.testIdentifyFlagCard.executor": "Debug", - "JUnit.EmailValidatorTest.executor": "Run", - "JUnit.MainTest.executor": "Run", - "JUnit.SimpleMathTest.executor": "Run", - "JUnit.UtilsTest.executor": "Run", - "JUnit.ValidateTest.executor": "Run", - "JUnit.ValidatorTest.executor": "Run", - "Maven.multiform-validator [test].executor": "Run", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "git-widget-placeholder": "main", - "kotlin-language-version-configured": "true", - "project.structure.last.edited": "Project", - "project.structure.proportion": "0.15", - "project.structure.side.proportion": "0.2", - "run.code.analysis.last.selected.profile": "pProject Default", - "settings.editor.selected.configurable": "preferences.pluginManager" + - +}]]> +