Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5fdd5b1
Update security_quality_gate.py
bkaiserinfosec Mar 13, 2024
1a5e69e
Update Jenkinsfile
bkaiserinfosec Mar 13, 2024
12cbbd2
Update security_quality_gate.py
bkaiserinfosec Mar 13, 2024
ffcd643
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/update-secu…
bkaiserinfosec Mar 13, 2024
c5242c9
update settings and groups
bkaiserinfosec Mar 18, 2024
21ff0cd
add function for table updates
bkaiserinfosec Mar 18, 2024
cfcaab3
updated function for db updates
bkaiserinfosec Mar 18, 2024
fe69827
Update updates.py
bkaiserinfosec Mar 18, 2024
b84553c
Update updates.py
bkaiserinfosec Mar 18, 2024
1c6d5c0
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/fix-syntax-…
bkaiserinfosec Mar 18, 2024
fa80754
Update updates.py
bkaiserinfosec Mar 18, 2024
2e3e85c
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/fix-syntax-…
bkaiserinfosec Mar 18, 2024
7db0df8
Update settings.py
bkaiserinfosec Mar 20, 2024
1e5bddf
update to settings update without restart
bkaiserinfosec Mar 22, 2024
d0f7120
Update run.py
bkaiserinfosec Mar 22, 2024
17aeb1c
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/fix-syntax-…
bkaiserinfosec Mar 22, 2024
ba8b3dc
Update pipeline-config.yaml
bkaiserinfosec Mar 22, 2024
42f91fd
Update __init__.py
bkaiserinfosec Mar 22, 2024
6642feb
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
89ec1ba
Update __init__.py
bkaiserinfosec Mar 22, 2024
61c8474
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
9f3a6d2
Update jenkins_webhook.py
bkaiserinfosec Mar 22, 2024
68b7189
Update jenkins_webhook.py
bkaiserinfosec Mar 22, 2024
ba2a700
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
685167e
Update jenkins_webhook.py
bkaiserinfosec Mar 22, 2024
9762718
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
9f24393
Update jenkins_webhook.py
bkaiserinfosec Mar 22, 2024
9b1a8cb
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
a843f29
Update jenkins_webhook.py
bkaiserinfosec Mar 22, 2024
926a746
Merge branch 'release/0.1.0-beta/Prod-azure' into feature/jenkins-upd…
bkaiserinfosec Mar 22, 2024
c3d91be
add new route for updating application profile
bkaiserinfosec Mar 23, 2024
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
26 changes: 19 additions & 7 deletions src/vr/api/vulns/jenkins_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,21 @@ def add_application_sla_policy(app_id):
# Global dictionary to keep track of report statuses
report_statuses = {}

# Create a logger object for this module or function
logger = logging.getLogger('add_new_scan')
logger.setLevel(logging.INFO) # Set the desired log level

# Create a stream handler to output logs to stdout
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)

# Optionally, set a formatter for the handler
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
stream_handler.setFormatter(formatter)

# Add the handler to the logger
logger.addHandler(stream_handler)
def add_new_scan(git_url, branch_name, report_id):
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

try:
stage_str = _determine_stages_for_app(git_url, branch_name)
Expand All @@ -232,13 +244,13 @@ def add_new_scan(git_url, branch_name, report_id):
url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters"
resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY']))
# Log the response details
logging.info(f"Request URL: {url}")
logging.info(f"Response Status Code: {resp.status_code}")
logging.info(f"Response Text: {resp.text}")
logger.info(f"Request URL: {url}")
logger.info(f"Response Status Code: {resp.status_code}")
logger.info(f"Response Text: {resp.text}")
except requests.exceptions.Timeout:
logging.error('Processing Error: Timeout')
logger.error('Processing Error: Timeout')
except Exception as e:
logging.error(f'Unexpected error: {str(e)}')
logger.error(f'Unexpected error: {str(e)}')


def _determine_stages_for_app(git_url, branch_name):
Expand Down
20 changes: 14 additions & 6 deletions src/vr/templates/vulns/application_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ <h3 class="has-filters mb-0">
Application Profile
</h3>





</div>
</div>

Expand All @@ -57,7 +53,18 @@ <h3 class="modal-title" id="updateAppProfileModalLabel">Update Application Profi
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="/update_application_profile" method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="app_name" value="{{ app_data.ApplicationName }}"/>
<div class="form-group">
<label for="gitUrl" style="margin-right: 64px;">Git URL:</label>
<input type="text" class="form-control" id="gitUrl" name="gitUrl" value="{{ app_data.RepoURL }}">
</div>
<div class="form-group">
<label for="gitBranch" style="margin-right: 42px;">Git Branch:</label>
<input type="text" class="form-control" id="gitBranch" name="gitBranch" value="main">
</div>
<div class="modal-body">
<div class="form-group">
<label for="emailDistributionUpdate">Email Distribution List (optional):</label>
<input type="text" class="form-control" id="emailDistributionUpdate" placeholder="Enter email distribution list">
Expand All @@ -66,8 +73,9 @@ <h3 class="modal-title" id="updateAppProfileModalLabel">Update Application Profi
<p>NOTE: This will perform an Application Profile Assessment on the OnDemand Security Pipeline. This process can take up to 1 hour to complete and the results will be emailed to your registered email in addition to the optional Email distribution list entered above.</p>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
Expand Down
41 changes: 40 additions & 1 deletion src/vr/vulns/web/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,45 @@ def on_demand_testing():
return redirect(request.referrer)


@vulns.route("/update_application_profile", methods=['POST'])
@login_required
def update_application_profile():
NAV['curpage'] = {"name": "Vulnerability Scans"}
admin_role = 'Application Admin'
role_req = ['Application Admin', 'Application Viewer']
perm_entity = 'Application'
user, status, user_roles = _auth_user(session, NAV['CAT']['name'], role_requirements=role_req,
permissions_entity=perm_entity)
status = _entity_page_permissions_filter(id, user_roles, session, admin_role)

if status == 401:
return redirect(url_for('admin.login'))
elif status == 403:
return render_template('403.html', user=user, NAV=NAV)

git_url = request.form.get('gitUrl')
git_branch = request.form.get('gitBranch')
app_name = request.form.get('app_name')
tests_to_run = 'NONE,'

headers = {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
'token': app.config['JENKINS_TOKEN'],
'GIT_URL': git_url,
'TESTS': tests_to_run.upper(),
'GIT_BRANCH': git_branch,
'APP_NAME': app_name,
'PROFILE_APPLICATION': 'Y'
}
url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters"
resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY']))

return redirect(request.referrer)


@vulns.route("/application_profile/<app_id>")
@login_required
def application_profile(app_id):
Expand All @@ -145,7 +184,7 @@ def application_profile(app_id):
filter(lambda t: t.ID != '', assets_all)
)
app = BusinessApplications.query.filter(text(f'ID={app_id}')).first()
app_data = {'ID': app_id, 'ApplicationName': app.ApplicationName, 'Component': app.ApplicationAcronym}
app_data = {'ID': app_id, 'ApplicationName': app.ApplicationName, 'Component': app.ApplicationAcronym, 'RepoURL': app.RepoURL}
NAV['appbar'] = 'settings'
return render_template('vulns/application_profile.html', entities=assets, user=user,
NAV=NAV, app_data=app_data)
Expand Down