in src/advisor/helpers/java/java_tool_invoker.py [0:0]
def graviton_ready_assessor(self, file_path):
"""Calls the GravitonReadyAssessor tool with the specified path
Args:
file_path: The path to the JAR or WAR file
Returns:
0, message: If no native methods are found.
3, message: If native methods are found. Message will contain the Native methods found.
-1, message: If an exception occurrs.
"""
try:
if (not self.ensure_jar()):
return -1, 'Could not generate jar scanner'
java_process = subprocess.run(['java', '-cp', self.JAR_PATH, self.CLASS_NAME, file_path], capture_output=True)
if (java_process.returncode == 0):
return 0, 'No native methods found in scanned JAR files.'
if java_process.stderr and java_process.returncode != 3:
raise Exception(java_process.stderr.decode('utf-8'))
output = java_process.stdout.decode('utf-8')
lines = output.split('\n')
for line in lines:
if line.startswith('Native methods:'):
return 3, line
return java_process.returncode
except:
logging.debug('Error scanning JAR files.', exc_info=True)
return -1, f'Error scanning JAR files.'