-
Notifications
You must be signed in to change notification settings - Fork 7
/
APICheckmarx.py
103 lines (92 loc) · 2.5 KB
/
APICheckmarx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!usr/bin/python
###############################
# > Author: Duarte Monteiro
# > Version: 1.0
# > Vendor: www.checkmarx.com
# > Notes: RESTAPI for PyCheckMarx
###############################
# Python Dependencies
from flask import Flask, jsonify, request
app = Flask(__name__)
# Import PyCheckMarx
import PyCheckmarx
#
# Launch error to the user
#
def launchError(message):
return jsonify({"error":"%s" % message}), 500
#
# getProjectScannedDisplayData
#
@app.route('/APICX/getProjectScannedDisplayData/', methods=["GET"])
@app.route('/APICX/getProjectScannedDisplayData/', defaults={"extra_path": ""}, methods=["GET"])
@app.route('/APICX/getProjectScannedDisplayData/<int:projectID>', methods=["GET"])
def ProjectScannedDisplayData(projectID=None):
try:
if projectID == None:
return pyC.getProjectScannedDisplayData()
else:
return pyC.filterProjectScannedDisplayData(projectID)
except Exception as e:
return launchError(e.message)
#
# getProjectsDisplayData
#
@app.route('/APICX/getProjectsDisplayData/', methods=["GET"])
@app.route('/APICX/getProjectsDisplayData/<int:projectID>', methods=["GET"])
def ProjectsDisplayData(projectID=None):
try:
if projectID == None:
return pyC.getProjectsDisplayData()
else:
return pyC.filterProjectsDisplayData(projectID)
except Exception as e:
return launchError(e.message)
#
# getScanInfoForAllProjects
#
@app.route('/APICX/getScanInfoForAllProjects/', methods=["GET"])
@app.route('/APICX/getScanInfoForAllProjects/<int:projectID>', methods=["GET"])
def ScanInfoForAllProjects(projectID=None):
try:
if projectID == None:
return pyC.getScanInfoForAllProjects()
else:
return pyC.filterScanInfoForAllProjects(projectID)
except Exception as e:
return launchError(e.message)
#
# getPresetList
#
@app.route('/APICX/getPresetList/', methods=["GET"])
def PresetList():
try:
return pyC.getPresetList()
except Exception as e:
return launchError(e.message)
#
# getConfigurationList
#
@app.route('/APICX/getConfigurationList/', methods=["GET"])
def ConfigurationList():
try:
return pyC.getConfigurationList()
except Exception as e:
return launchError(e.message)
#
# getAssociatedGroups
#
@app.route('/APICX/getAssociatedGroups/', methods=["GET"])
def AssociatedGroups():
try:
return pyC.getAssociatedGroups()
except Exception as e:
return launchError(e.message)
#
# Trigger Flask App
#
if __name__ == '__main__':
print ("[SYS]\tLoading...")
pyC = PyCheckmarx.PyCheckmarx()
print ("[SYS]\tLoaded!")
app.run(debug=True, host="0.0.0.0", port=5000)