-
-
Notifications
You must be signed in to change notification settings - Fork 110
794 check for body validations and class validations #1277
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
Draft
sahilagichani14
wants to merge
23
commits into
develop
Choose a base branch
from
794-check-for-valid-modifier-combinations
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0572bdf
add wrapper around FieldModifier for validation
sahilagichani14 a190f4b
added test for FieldModifiersValidator
sahilagichani14 9780fa6
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
swissiety 8f5848e
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
sahilagichani14 0f81035
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
sahilagichani14 26b2c4e
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
sahilagichani14 eeee87a
Merge remote-tracking branch 'origin/794-check-for-valid-modifier-com…
sahilagichani14 f462e98
implement BodyValidationInterceptor, ClassValidationInterceptor
sahilagichani14 bafb3b2
missed method param
sahilagichani14 ac63486
implement InvokeArgumentValidator
sahilagichani14 b3ea18f
implement CheckEscapingValidator
sahilagichani14 7211837
implement CheckEscapingValidator
sahilagichani14 4732cc9
implement InvokeValidator
sahilagichani14 e769aa1
implement ReturnStatementsValidator
sahilagichani14 ab2f192
implement CheckTypesValidator && enable them by default
sahilagichani14 9ea4757
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
sahilagichani14 4e4d842
fix license header failure && locale pkgName
sahilagichani14 e2048db
fix mvn com.spotify.fmt:fmt-maven-plugin:format
sahilagichani14 5e0184b
fix ClassValidationInterceptor
sahilagichani14 5cea9f1
disable bydefault validation interceptors
sahilagichani14 5bc5ed3
Merge branch 'develop' into 794-check-for-valid-modifier-combinations
sahilagichani14 1628711
Merge remote-tracking branch 'origin/develop' into 794-check-for-vali…
stschott 4388eff
add test cases for validators
stschott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
sootup.core/src/main/java/sootup/core/validation/CheckEscapingValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package sootup.core.validation; | ||
|
|
||
| /*- | ||
| * #%L | ||
| * Soot - a J*va Optimization Framework | ||
| * %% | ||
| * Copyright (C) 2025 Sahil Agichani | ||
| * %% | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation, either version 2.1 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Lesser Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Lesser Public | ||
| * License along with this program. If not, see | ||
| * <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
| * #L% | ||
| */ | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import sootup.core.jimple.common.expr.AbstractInvokeExpr; | ||
| import sootup.core.jimple.common.stmt.Stmt; | ||
| import sootup.core.model.Body; | ||
| import sootup.core.signatures.MethodSignature; | ||
| import sootup.core.types.Type; | ||
| import sootup.core.views.View; | ||
|
|
||
| public class CheckEscapingValidator implements BodyValidator { | ||
|
|
||
| @Override | ||
| public List<ValidationException> validate(Body body, View view) { | ||
| List<ValidationException> validationException = new ArrayList<>(); | ||
|
|
||
| for (Stmt stmt : body.getStmts()) { | ||
| if (stmt.isInvokableStmt()) { | ||
| Optional<AbstractInvokeExpr> invokeExprOpt = stmt.asInvokableStmt().getInvokeExpr(); | ||
| if (invokeExprOpt.isPresent()) { | ||
| MethodSignature ref = invokeExprOpt.get().getMethodSignature(); | ||
| if (ref.getName().contains("'") | ||
| || ref.getDeclClassType().getFullyQualifiedName().contains("'")) { | ||
| validationException.add( | ||
| new ValidationException(stmt, "Escaped name found in signature")); | ||
| } | ||
| for (Type paramType : ref.getParameterTypes()) { | ||
| if (paramType.toString().contains("'")) { | ||
| validationException.add( | ||
| new ValidationException(stmt, "Escaped name found in signature")); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return validationException; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.