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

Updated to python3, java11 #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
19 changes: 16 additions & 3 deletions CheckerPrinter/src/checkerprinter/InMemory.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,22 @@ protected boolean initCheckerArgs(JsonObject optionsObject) {
this.exceptionMsg = "Error: Cannot find indicated checker.";
return false;
}
/*
"-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"-processorpath", "$CHECKERFRAMEWORK/checker/dist/checker.jar",
"-cp", "$CHECKERFRAMEWORK/checker/dist/checker-qual.jar",
*/
this.checkerOptionsList =
Arrays.asList(
"-Xbootclasspath/p:" + this.CHECKER_FRAMEWORK + "/checker/dist/jdk8.jar",

"-processor",
checker);
if (optionsObject.getBoolean("has_cfg")) {
Expand Down Expand Up @@ -150,10 +163,10 @@ protected boolean initCheckerArgs(JsonObject optionsObject) {

List<Diagnostic<? extends JavaFileObject>> diagnosticList = errorCollector.getDiagnostics();

assert this.checkerOptionsList.size() > 1 : "at least should have -Xbootclasspath/p: flag";
assert this.checkerOptionsList.size() > 1 : "at least should have -Xbootclasspath/a: flag";

this.checkerPrinter.setExecCmd(
this.checkerOptionsList.subList(1, this.checkerOptionsList.size()));
this.checkerOptionsList.subList(0, this.checkerOptionsList.size()));

if (bytecode != null && diagnosticList.size() == 0) {
this.checkerPrinter.printSuccess();
Expand Down
4 changes: 2 additions & 2 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _e():
from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote
urlunquote = functools.partial(urlunquote, encoding='latin1')
from http.cookies import SimpleCookie
from collections import MutableMapping as DictMixin
from collections.abc import MutableMapping as DictMixin
import pickle
from io import BytesIO
from configparser import ConfigParser, Error as ConfigParserError
Expand Down Expand Up @@ -178,7 +178,7 @@ def next(it):

bytes = str
else: # 2.6, 2.7
from collections import MutableMapping as DictMixin
from collections.abc import MutableMapping as DictMixin
unicode = unicode
json_loads = json_lds
eval(compile('def _raise(*a): raise a[0], a[1], a[2]', '<py3fix>', 'exec'))
Expand Down
8 changes: 5 additions & 3 deletions bottle_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
app = Bottle()
default_app.push(app)

import StringIO # NB: don't use cStringIO since it doesn't support unicode!!!
from io import StringIO # NB: don't use cStringIO since it doesn't support unicode!!!
import json
# import pg_logger
import urllib
import urllib2
##import urllib2

appPath = dirname(abspath(__file__))

Expand All @@ -63,13 +63,15 @@ def get_exec():
java_backend = subprocess.Popen(['./shell-scripts/run-checker.sh', request.query.frontend_data.encode('utf8'),
cfPath, str(isRise4Fun)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = java_backend.communicate()

print("Java backend output: %d %s %s" % (java_backend.returncode,stdout, stderr)) ## added for debugging
if java_backend.returncode != 0:
print ("Error: CheckerPrinter failed %d %s %s" % (java_backend.returncode,stdout, stderr))
result = json.dumps({'backend_status':'exception', 'exception_msg':'500 Server Internal Error.'})
else:
result = stdout
response.add_header("Content-Type", "application/json")
return result
return result

if __name__ == "__main__":
run(host='127.0.0.1', port=8081, reloader=True)
Expand Down
2 changes: 1 addition & 1 deletion shell-scripts/run-checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ fi
CF=$2
IS_RISE4FUN=$3

cat <<ENDEND | $JAVA_HOME/bin/java -Xmx2500M -Xbootclasspath/p:$CF/checker/dist/javac.jar -ea -ea:com.sun.tools... -cp $CF/checker/dist/checker.jar:../CheckerPrinter/bin:../CheckerPrinter/javax.json-1.0.jar:$JAVA_HOME/lib/tools.jar checkerprinter.InMemory $CF $IS_RISE4FUN
cat <<ENDEND | $JAVA_HOME/bin/java -Xmx2500M -Xbootclasspath/a:$CF/checker/dist/javac.jar -ea -ea:com.sun.tools... -cp $CF/checker/dist/checker.jar:../CheckerPrinter/bin:../CheckerPrinter/javax.json-1.0.jar:$JAVA_HOME/lib/tools.jar checkerprinter.InMemory $CF $IS_RISE4FUN
Copy link

Choose a reason for hiding this comment

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

💬 5 similar findings have been found in this PR


SC2086: Double quote to prevent globbing and word splitting.


🔎 Expand here to view all instances of this finding
File Path Line Number
shell-scripts/run-checker.sh 25
shell-scripts/run-checker.sh 25
shell-scripts/run-checker.sh 25
shell-scripts/run-checker.sh 25
shell-scripts/run-checker.sh 25

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

$1
ENDEND