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

Sensitive api #20

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b5b5ef3
first test, create numberOfInterface
FHandrick Sep 24, 2020
01ce561
add jar file
FHandrick Sep 24, 2020
50d4459
add new method classIdentification
FHandrick Sep 25, 2020
fd05310
add new method methodsName
FHandrick Sep 28, 2020
763c325
add new method methodSignatureList
FHandrick Sep 30, 2020
cef007f
Merge remote-tracking branch 'origin' into sensitive-API
FHandrick Oct 1, 2020
9f8fe89
return method adapted to string
FHandrick Oct 1, 2020
c50a194
transform file format
FHandrick Oct 6, 2020
dd349e0
transform file format
FHandrick Oct 6, 2020
e284708
Merge branch 'master' of https://github.com/PAMunb/JimpleFramework in…
leomarcamargo Oct 6, 2020
3f4ad22
Merge branch 'master' into sensitive-API
luisamaralh Oct 6, 2020
f0b8ef0
Merge branch 'master' into sensitive-API
luisamaralh Oct 6, 2020
0ccac78
Merge branch 'master' of https://github.com/PAMunb/JimpleFramework in…
leomarcamargo Oct 6, 2020
c103971
new SensitiveAPI module
FHandrick Oct 6, 2020
dfe89fc
Merge branch 'sensitive-API' of https://github.com/PAMunb/JimpleFrame…
leomarcamargo Oct 6, 2020
3d478a2
add file.txt
FHandrick Oct 6, 2020
b762690
Criando módulo sensitivo
leomarcamargo Oct 6, 2020
12a13c6
Merge branch 'sensitive-API' of https://github.com/PAMunb/JimpleFrame…
leomarcamargo Oct 6, 2020
98d3f73
Renomeando arquivo
leomarcamargo Oct 6, 2020
e2a7504
Merge pull request #18 from leomarcamargo/sensitive-API
luisamaralh Oct 6, 2020
4f81782
testing sensitive-method
FHandrick Oct 6, 2020
ebafd9e
sensitiveAPI witout refectore
FHandrick Oct 8, 2020
35abd0a
Merge branch 'master' into sensitive-API
luisamaralh Oct 8, 2020
b04ceaa
merged sensitive-api to the new archtecture
luisamaralh Oct 29, 2020
2b01730
remove 2 tests methods
FHandrick Nov 5, 2020
10b2326
Merge branch 'master' into sensitive-API
FHandrick Dec 17, 2020
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
37 changes: 27 additions & 10 deletions src/main/rascal/lang/jimple/toolkit/BasicMetrics.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,48 @@ module lang::jimple::toolkit::BasicMetrics

import lang::jimple::core::Syntax;
import lang::jimple::core::Context;
import List;

/**
* Computes the number of classes from
* an ExecutionContext.
*/
* Computes the number of classes from
* an ExecutionContext.
*/
public int numberOfClasses(ExecutionContext ctx) {
int total = 0;
top-down visit(ctx) {
case classDecl(_, _, _, _, _, _): total = total + 1;
case classDecl(_, _, _, _, _, _): total = total + 1;
}
return total;
return total;
}

public list[str] classIdentification(ExecutionContext ctx) {
list[str] cl = [];
top-down visit(ctx) {
case classDecl(_, _, _, _, _, list[Method] methods): cl = cl + ["classDecl(_, _, _, _, _, <methods>)"];
}
return cl;
}

public list[Method] methodsIdentification(ExecutionContext ctx) {
list[Method] lm = [];
top-down visit(ctx) {
case classDecl(_, _, _, _, _, list[Method] methods): lm = lm + methods;
}
return lm;
}

/**
* Computes the number of public methods from an
* execution context.
*/
* Computes the number of public methods from an
* execution context.
*/
public int numberOfPublicMethods(ExecutionContext ctx) {
int total = 0;
top-down visit(ctx) {
case method(ms, _, _, _, _, _): {
case method(ms, _, _, _, _, _): {
if(Public() in ms) {
total = total + 1;
}
}
}
return total;
return total;
}
58 changes: 58 additions & 0 deletions src/main/rascal/lang/jimple/toolkit/SensitiveAPI.rsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module lang::jimple::toolkit::SensitiveAPI

import lang::jimple::core::Context;
import lang::jimple::Syntax;
import lang::jimple::core::Context;
import lang::jimple::util::Converters;
import IO;
import List;
import String;


public list[str] sensitiveFind(loc fileSensitive){
es = [];
list[str] listSignature = execute([|project://JimpleFramework/src/test/resources|], es, Analysis(methodSignatureList));
list[str] listFileSensitive = readFiles(fileSensitive);
list[str] listResult = listFileSensitive & listSignature;
return listResult;
}


public list[str] methodSignatureList(ExecutionContext ctx){
list[str] mS = [];
top-down visit(ctx) {
case invokeStmt(specialInvoke(_,methodS,_)): mS = mS+signature(methodS);
case invokeStmt(virtualInvoke(_,methodS,_)): mS = mS+signature(methodS);
case invokeStmt(interfaceInvoke(_,methodS,_)): mS = mS+signature(methodS);
case invokeStmt(staticMethodInvoke(methodS,_)): mS = mS+signature(methodS);
case invokeStmt(dynamicInvoke(methodS,_,_,_)): mS = mS+signature(methodS);
}
return mS;
}

public list[str] readFiles(loc location){
res = [];
list[str] lines = readFileLines(location);
for (str l <- lines){
res = res + changeLine(l);
};
return res;
}

public str changeLine(str s){
str stringFinal = replaceAll(s, "\<", "");
stringFinal = replaceAll(stringFinal, "\>", "");

list[str] partes = split(" ", stringFinal);

if (size(partes) >=3) {
str caminho = replaceAll(partes[0], ":", "");
caminho = replaceAll(caminho, ".", "/");
str retorno = partes[1];
retorno = replaceAll(retorno, ".", "/");
str metodo = partes[2];
return caminho + "." + metodo;
};

return "";
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should discuss again this implementation. IMO, we should simplify the interface of the sensitiveFind function. Actually, even the name is not really good. It should receive two arguments: a list of strings with the signature of sensitive methods and an ExecutionContext. Only in this way I could use this implementation in a pipeline with a set of analyzes. This is a bit tough to explain here.

Loading