Skip to content

feat(ui): Add option to define custom css and js #11586

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

kiblik
Copy link
Contributor

@kiblik kiblik commented Jan 16, 2025

Custom styles (in CSS) are beneficial if you are running DD in the company and you would like to add some corporate colors.

@github-actions github-actions bot added settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR ui labels Jan 16, 2025
Copy link

dryrunsecurity bot commented Jan 16, 2025

DryRun Security Summary

A Django DefectDojo PR introduces global configuration for custom CSS and JavaScript files, presenting potential security risks including XSS vulnerabilities, malicious file inclusion, configuration exposure, and CSP implications.

Expand for full summary

The PR adds global configuration for custom CSS and JavaScript files across the Django DefectDojo application, enabling dynamic UI customization with potential security implications. Security findings include:

  1. XSS Vulnerability Risk: In dojo/context_processors.py, the addition of CUSTOM_CSS and CUSTOM_JS could introduce Cross-Site Scripting (XSS) vulnerabilities if these settings are not properly sanitized before rendering.

  2. Potential Malicious File Inclusion: In dojo/templates/base.html, while using {% static %} provides some protection, there's an implicit risk of including potentially unsafe external scripts and stylesheets.

  3. Configuration Exposure: The global exposure of custom configuration settings could potentially leak information about the application's customization.

  4. Content Security Policy (CSP) Implications: Dynamically including external scripts and stylesheets could potentially bypass strict Content Security Policy settings.

Code Analysis

We ran 7 analyzers against 3 files and 0 analyzers had findings. 7 analyzers had no findings.

View PR in the DryRun Dashboard.

Copy link

DryRun Security Summary

The pull request adds the ability to include custom JavaScript and CSS files in DefectDojo through new settings, enabling application customization while emphasizing the importance of carefully vetting these files for potential security risks.

Expand for full summary

Summary:

The code changes in this pull request focus on adding the ability to include custom JavaScript and CSS files in the DefectDojo application. This is achieved by introducing two new settings, DD_CUSTOM_CSS and DD_CUSTOM_JS, which allow administrators to specify the paths to custom CSS and JavaScript files, respectively. These files are then included in the base HTML template of the application.

From an application security perspective, these changes provide a way for developers and administrators to extend the functionality and styling of the DefectDojo application. However, it is crucial to ensure that the custom CSS and JavaScript files are properly vetted and do not introduce any security vulnerabilities, such as cross-site scripting (XSS) or code injection issues. Developers should review the content of these files and ensure that they are properly sanitized and validated before including them in the application.

Additionally, it is recommended to implement a secure process for managing and updating these custom files, such as using a version control system and implementing appropriate access controls and review processes. This will help to mitigate the potential risks associated with the introduction of custom code into the application.

Files Changed:

  1. dojo/templates/base.html: This file has been updated to include new sections for loading custom JavaScript and CSS files, if the CUSTOM_JS and CUSTOM_CSS variables are set, respectively. This provides a way for developers to easily extend the functionality and styling of the DefectDojo application.

  2. dojo/settings/settings.dist.py: Two new settings, DD_CUSTOM_CSS and DD_CUSTOM_JS, have been added to the Django application's configuration. These settings allow administrators to specify the paths to custom CSS and JavaScript files, which will be included in the application's user interface.

  3. dojo/context_processors.py: The globalize_vars function has been updated to include two new context variables, CUSTOM_CSS and CUSTOM_JS, which are likely used to provide the custom CSS and JavaScript file paths to the application's templates.

Code Analysis

We ran 9 analyzers against 3 files and 0 analyzers had findings. 9 analyzers had no findings.

View PR in the DryRun Dashboard.

@kiblik
Copy link
Contributor Author

kiblik commented Jan 24, 2025

@mtesauro or @Maffooch any feedback regarding this proposal?

@zet-mar
Copy link

zet-mar commented Feb 4, 2025

From my point of view, it could be beneficial not just for our company but also for all the others who have defined company design.
Currently, it is possible to solve this but by "ugly hack," which will be solved by this implementation. Can you review it and push it forward to production 🙏
Thank you in advance.

@valentijnscholten
Copy link
Member

It could be useful. I wonder if we should add a comment about the risks of including/injecting javascript?

@kiblik
Copy link
Contributor Author

kiblik commented Feb 28, 2025

It could be useful. I wonder if we should add a comment about the risks of including/injecting javascript?

Thank you for the review. Where should I place it? To release notes? Or to the settings.dist.py file, next to the definition?

@valentijnscholten
Copy link
Member

Or to the settings.dist.py file, next to the definition?

I vote for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants