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

New detector for MET03-J #2447

Merged
merged 83 commits into from
Jun 19, 2023
Merged

Conversation

NazirMuhammadZafarIqbal
Copy link
Contributor

@NazirMuhammadZafarIqbal NazirMuhammadZafarIqbal commented Jun 11, 2023

I have implemented a checker named "FindVulnerableSecurityCheckMethods" for SEI CERT MET03-J

The checker proved to be effective in identifying potential security vulnerabilities in Java code. By enforcing the declaration of methods that use security checks as private or final, this checker helps reduce the risk of security breaches.

I have both White Box and Black Box Testing. For White Box Testing, I have created 5 compliant and 18 non-compliant test cases. My checker passes all of the test cases. For Black Box Testing, I tested the checker on Elasticsearch and SpotBugs projects. In the Elasticsearch project, there was no detection (As it is not using SecurityManager class). In SpotBugs, I got 6 true positives and 0 false positives.

Results for Eclipse:
output_Eclipse.txt

Results for spotbugs Project:
5.0_SBTestRepoMessageandTestsFixing.txt

Detections by MET03-J in SpotBugs:
5.0_SBTestRepoMessageandTestsFixing_filtered.txt

Details and link to detections:
True Positive in javax.activation.CommandMap.setCommandMap: M V VSC: The method 'javax.activation.CommandMap.setDefaultCommandMap(CommandMap)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At CommandMap.java:[line 57]

True Positive in [javax.activation.FileTypeMap.setDefaultFileTypeMap]:(https://github.com/kohsuke/javax.activation/blob/90efa5762cd2004076eb473b22e527ab02bd2e49/src/main/java/javax/activation/FileTypeMap.java#L98): M V VSC: The method 'javax.activation.FileTypeMap.setDefaultFileTypeMap(FileTypeMap)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At FileTypeMap.java:[line 68]

True Positive in javax.activation.DataHandler.setDataContentHandlerFactory: M V VSC: The method 'javax.activation.DataHandler.setDataContentHandlerFactory(DataContentHandlerFactory)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At DataHandler.java:[line 619]

True Positive in bugIdeas.Ideas_2011_08_10.setSecurityManager: M V VSC: The method 'bugIdeas.Ideas_2011_08_10.setSecurityManager(SecurityManager)' performs security check by using 'SecurityManager.checkPackageAccess(String)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At Ideas_2011_08_10.java:[line 52]

True Positive in ReflectionIncreaseAccessibilityNegativeTest.create: M V VSC: The method 'ReflectionIncreaseAccessibilityNegativeTest.create(Class)' performs security check by using 'SecurityManager.checkPackageAccess(String)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At ReflectionIncreaseAccessibilityNegativeTest.java:[line 21]

True Positive in (couldn't find the link. In the repo, this file is in a jar so couldn't get URL) M V VSC: The method 'javax.security.jacc.PolicyConfigurationFactory.getPolicyConfigurationFactory()' performs security check by using 'SecurityManager.checkPermission(Permission)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At PolicyConfigurationFactory.java:[line 82]

True Positive in javax.activation.CommandMap.setCommandMap: M V VSC: The method 'javax.activation.CommandMap.setDefaultCommandMap(CommandMap)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At CommandMap.java:[line 57]

True Positive in [javax.activation.FileTypeMap.setDefaultFileTypeMap]:(https://github.com/kohsuke/javax.activation/blob/90efa5762cd2004076eb473b22e527ab02bd2e49/src/main/java/javax/activation/FileTypeMap.java#L98): M V VSC: The method 'javax.activation.FileTypeMap.setDefaultFileTypeMap(FileTypeMap)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At FileTypeMap.java:[line 68]

True Positive in javax.activation.DataHandler.setDataContentHandlerFactory: M V VSC: The method 'javax.activation.DataHandler.setDataContentHandlerFactory(DataContentHandlerFactory)' performs security check by using 'SecurityManager.checkSetFactory()' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At DataHandler.java:[line 619]

True Positive in bugIdeas.Ideas_2011_08_10.setSecurityManager: M V VSC: The method 'bugIdeas.Ideas_2011_08_10.setSecurityManager(SecurityManager)' performs security check by using 'SecurityManager.checkPackageAccess(String)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At Ideas_2011_08_10.java:[line 52]

True Positive in ReflectionIncreaseAccessibilityNegativeTest.create: M V VSC: The method 'ReflectionIncreaseAccessibilityNegativeTest.create(Class)' performs security check by using 'SecurityManager.checkPackageAccess(String)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At ReflectionIncreaseAccessibilityNegativeTest.java:[line 21]

True Positive in (couldn't find the link. In the repo, this file is in a jar so couldn't get URL) M V VSC: The method 'javax.security.jacc.PolicyConfigurationFactory.getPolicyConfigurationFactory()' performs security check by using 'SecurityManager.checkPermission(Permission)' method of Security Manager Class, but is overrideable. Declare the method final or private in order to resolve the issue. At PolicyConfigurationFactory.java:[line 82]


Make sure these boxes are checked before submitting your PR -- thank you!

  • Added an entry into CHANGELOG.md if you have changed SpotBugs code

Added Checker as well.
Added test cases calsses.
Added Checker as well.
Added test cases calsses.
Added test class (JUnit) as well.
Added Checker as well.
Added test cases calsses.
Added test class (JUnit) as well.
Edited the Changelog.md.
Added Checker as well.
Added test cases calsses.
Added test class (JUnit) as well.
Edited the Changelog.md.
Fixed the formatting issues as well.
If one of the stream-returning methods (doubles, ints, or longs) is called on
Random or SecureRandom, don't report that the Random was only used once

Fixes spotbugs#2370
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…bugs#2376)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…potbugs#2377)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…2381)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2385)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
spotbugs#2383)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2382)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2387)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2390)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2393)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…potbugs#2394)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Issue-543 Store Java class annotation names to PackageMemberAnnotations

* Issue-543 Store Java class annotation names to PackageMemberAnnotations

* Issue-543 Add AnnotationMatcher for filtering (with test cases)

* Issue-543 Extend SAX handler for AnnotationMatcher and classjas attr

* Issue-543 Fix whitespaces

* Issue-543 Add CHANGELOG entry

* Issue-543 Make compatible with Java 1.8

* Issue-543 Extract code to addJavaAnnotationNames method

* Issue-543 Update filter file xml schema

* Issue-543 Run spotlessApply

* Issue-543 Fix AnnotationMatcherTest

* Issue-543 Fix file header comments

* Issue-543 Use MethodHandles for logger

* Issue 543 Fix documentation

* Issue 543 Combine expressions when getting annotation type

* Issue 543 Rename attribute classjas to classAnnotationNames

* Issue-543 Fix whitespaces

* Issue-543: Fix typo

---------

Co-authored-by: Philipp Sadler <philipp.sadler@gebit.de>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…33.0 (spotbugs#2399)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…bugs#2403)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
spotbugs#2405)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
NazirMuhammadZafarIqbal and others added 23 commits May 21, 2023 23:23
Fixed bug reporting message.
Fixed the private methods with 1 usage only.
# Conflicts:
#	CHANGELOG.md
#	spotbugs/etc/findbugs.xml
#	spotbugs/etc/messages.xml
@NazirMuhammadZafarIqbal NazirMuhammadZafarIqbal changed the title MET03-J New detector for MET03-J Jun 18, 2023
@hazendaz hazendaz self-assigned this Jun 19, 2023
@hazendaz hazendaz merged commit 073d870 into spotbugs:master Jun 19, 2023
5 checks passed
@hazendaz hazendaz added this to the SpotBugs 4.8.0 milestone Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants