code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
def test_it_ignores_bad_tz(self): form = {"identity": "alice@example.org", "tz": "Foo/Bar"} r = self.client.post("/accounts/signup/", form) self.assertContains(r, "Account created") self.assertIn("auto-login", r.cookies) profile = Profile.objects.get() self.assertEq...
0
Python
CWE-203
Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/203.html
vulnerable
def test_it_works(self): form = {"identity": "alice@example.org", "tz": "Europe/Riga"} r = self.client.post("/accounts/signup/", form) self.assertContains(r, "Account created") self.assertIn("auto-login", r.cookies) # An user should have been created user = User.obj...
0
Python
CWE-203
Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/203.html
vulnerable
def login(request): form = forms.PasswordLoginForm() magic_form = forms.EmailLoginForm() if request.method == "POST": if request.POST.get("action") == "login": form = forms.PasswordLoginForm(request.POST) if form.is_valid(): return _check_2fa(request, form.us...
0
Python
CWE-203
Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/203.html
vulnerable
def signup(request): if not settings.REGISTRATION_OPEN: return HttpResponseForbidden() ctx = {} form = forms.SignupForm(request.POST) if form.is_valid(): email = form.cleaned_data["identity"] tz = form.cleaned_data["tz"] user = _make_user(email, tz) profile = Pro...
0
Python
CWE-203
Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/203.html
vulnerable
def _validate_source(source: str, run_id: str) -> None: if not is_local_uri(source): return if run_id: store = _get_tracking_store() run = store.get_run(run_id) source = pathlib.Path(local_file_uri_to_path(source)).resolve() run_artifact_dir = pathlib.Path(local_file_uri...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def is_local_uri(uri): """Returns true if this is a local file path (/foo or file:/foo).""" if uri == "databricks": return False if is_windows() and uri.startswith("\\\\"): # windows network drive path looks like: "\\<server name>\path\..." return False parsed_uri = urllib.pars...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def _init_server(backend_uri, root_artifact_uri): """ Launch a new REST server using the tracking store specified by backend_uri and root artifact directory specified by root_artifact_uri. :returns A tuple (url, process) containing the string URL of the server and a handle to the server pro...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_create_model_version_with_path_source(mlflow_client): name = "mode" mlflow_client.create_registered_model(name) exp_id = mlflow_client.create_experiment("test") run = mlflow_client.create_run(experiment_id=exp_id) response = requests.post( f"{mlflow_client.tracking_uri}/api/2.0/mlf...
0
Python
CWE-23
Relative Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/23.html
vulnerable
def predict(self, model_uri, input_path, output_path, content_type): """ Generate predictions using generic python model saved with MLflow. The expected format of the input JSON is the Mlflow scoring format. Return the prediction results as a JSON. """ local_path = _d...
0
Python
CWE-36
Absolute Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/36.html
vulnerable
def predict(self, model_uri, input_path, output_path, content_type): """ Generate predictions using generic python model saved with MLflow. The expected format of the input JSON is the Mlflow scoring format. Return the prediction results as a JSON. """ local_path = _d...
0
Python
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def get_cmd( model_uri: str, port: int = None, host: int = None, timeout: int = None, nworkers: int = None ) -> Tuple[str, Dict[str, str]]: local_uri = path_to_local_file_uri(model_uri) timeout = timeout or MLFLOW_SCORING_SERVER_REQUEST_TIMEOUT.get() # NB: Absolute windows paths do not work with mlflow ...
0
Python
CWE-36
Absolute Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/36.html
vulnerable
def get_cmd( model_uri: str, port: int = None, host: int = None, timeout: int = None, nworkers: int = None ) -> Tuple[str, Dict[str, str]]: local_uri = path_to_local_file_uri(model_uri) timeout = timeout or MLFLOW_SCORING_SERVER_REQUEST_TIMEOUT.get() # NB: Absolute windows paths do not work with mlflow ...
0
Python
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def create_user(): content_type = request.headers.get("Content-Type") if content_type == "application/x-www-form-urlencoded": username = request.form["username"] password = request.form["password"] if store.has_user(username): flash(f"Username has already been taken: {userna...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def to_html(self) -> str: """ Returns a rendered HTML representing the content of the tab. :return: a HTML string """ import jinja2 j2_env = jinja2.Environment(loader=jinja2.BaseLoader()).from_string(self.template) return j2_env.render({**self._context})
0
Python
CWE-1336
Improper Neutralization of Special Elements Used in a Template Engine
The product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine.
https://cwe.mitre.org/data/definitions/1336.html
vulnerable
def is_local_uri(uri, is_tracking_or_registry_uri=True): """ Returns true if the specified URI is a local file path (/foo or file:/foo). :param uri: The URI. :param is_tracking_uri: Whether or not the specified URI is an MLflow Tracking or MLflow Model Registry URI. Examples...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def validate_path_is_safe(path): """ Validates that the specified path is safe to join with a trusted prefix. This is a security measure to prevent path traversal attacks. A valid path should: not contain separators other than '/' not contain .. to navigate to parent dir in path ...
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def validate_path_is_safe(path): """ Validates that the specified path is safe to join with a trusted prefix. This is a security measure to prevent path traversal attacks. A valid path should: not contain separators other than '/' not contain .. to navigate to parent dir in path ...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_list_artifacts_malicious_path(http_artifact_repo, path): with mock.patch( "mlflow.store.artifact.http_artifact_repo.http_request", return_value=MockResponse( { "files": [ {"path": path, "is_dir": False, "file_size": 1}, ] ...
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_list_artifacts_malicious_path(http_artifact_repo, path): with mock.patch( "mlflow.store.artifact.http_artifact_repo.http_request", return_value=MockResponse( { "files": [ {"path": path, "is_dir": False, "file_size": 1}, ] ...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_validate_path_is_safe_windows_good(path): validate_path_is_safe(path)
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_validate_path_is_safe_windows_good(path): validate_path_is_safe(path)
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def assert_response(resp): assert resp.status_code == 400 assert response.json() == { "error_code": "INVALID_PARAMETER_VALUE", "message": f"Invalid path: {invalid_path}", }
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def assert_response(resp): assert resp.status_code == 400 assert response.json() == { "error_code": "INVALID_PARAMETER_VALUE", "message": f"Invalid path: {invalid_path}", }
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_path_validation(mlflow_client): experiment_id = mlflow_client.create_experiment("tags validation") created_run = mlflow_client.create_run(experiment_id) run_id = created_run.info.run_id invalid_path = "../path" def assert_response(resp): assert resp.status_code == 400 asser...
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_path_validation(mlflow_client): experiment_id = mlflow_client.create_experiment("tags validation") created_run = mlflow_client.create_run(experiment_id) run_id = created_run.info.run_id invalid_path = "../path" def assert_response(resp): assert resp.status_code == 400 asser...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_validate_path_is_safe_windows_bad(path): with pytest.raises(MlflowException, match="Invalid path"): validate_path_is_safe(path)
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_validate_path_is_safe_windows_bad(path): with pytest.raises(MlflowException, match="Invalid path"): validate_path_is_safe(path)
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_validate_path_is_safe_good(path): validate_path_is_safe(path)
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_validate_path_is_safe_good(path): validate_path_is_safe(path)
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def test_validate_path_is_safe_bad(path): with pytest.raises(MlflowException, match="Invalid path"): validate_path_is_safe(path)
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_validate_path_is_safe_bad(path): with pytest.raises(MlflowException, match="Invalid path"): validate_path_is_safe(path)
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def load(self, dst_path=None) -> str: """ Downloads the dataset source to the local filesystem. :param dst_path: Path of the local filesystem destination directory to which to download the dataset source. If the directory does not exist, it is created. If ...
0
Python
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def list_artifacts(self, path=None): with self.get_ftp_client() as ftp: artifact_dir = self.path list_dir = posixpath.join(artifact_dir, path) if path else artifact_dir if not self._is_dir(ftp, list_dir): return [] artifact_files = ftp.nlst(lis...
0
Python
CWE-29
Path Traversal: '\..\filename'
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory.
https://cwe.mitre.org/data/definitions/29.html
vulnerable
def _create_multipart_upload_artifact(artifact_path): """ A request handler for `POST /mlflow-artifacts/mpu/create` to create a multipart upload to `artifact_path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) request_message = _get_request_message...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def get_artifact_handler(): from querystring_parser import parser query_string = request.query_string.decode("utf-8") request_dict = parser.parse(query_string, normalized=True) run_id = request_dict.get("run_id") or request_dict.get("run_uuid") path = request_dict["path"] validate_path_is_safe(...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _delete_artifact_mlflow_artifacts(artifact_path): """ A request handler for `DELETE /mlflow-artifacts/artifacts?path=<value>` to delete artifacts in `path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) _get_request_message(DeleteArtifact()) ...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _list_artifacts(): request_message = _get_request_message( ListArtifacts(), schema={ "run_id": [_assert_string, _assert_required], "path": [_assert_string], "page_token": [_assert_string], }, ) response_message = ListArtifacts.Response() if...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _abort_multipart_upload_artifact(artifact_path): """ A request handler for `POST /mlflow-artifacts/mpu/abort` to abort a multipart upload to `artifact_path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) request_message = _get_request_message( ...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def get_model_version_artifact_handler(): from querystring_parser import parser query_string = request.query_string.decode("utf-8") request_dict = parser.parse(query_string, normalized=True) name = request_dict.get("name") version = request_dict.get("version") path = request_dict["path"] va...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _download_artifact(artifact_path): """ A request handler for `GET /mlflow-artifacts/artifacts/<artifact_path>` to download an artifact from `artifact_path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) tmp_dir = tempfile.TemporaryDirectory() ...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _complete_multipart_upload_artifact(artifact_path): """ A request handler for `POST /mlflow-artifacts/mpu/complete` to complete a multipart upload to `artifact_path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) request_message = _get_request_m...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _list_artifacts_mlflow_artifacts(): """ A request handler for `GET /mlflow-artifacts/artifacts?path=<value>` to list artifacts in `path` (a relative path from the root artifact directory). """ request_message = _get_request_message(ListArtifactsMlflowArtifacts()) if request_message.HasField(...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _upload_artifact(artifact_path): """ A request handler for `PUT /mlflow-artifacts/artifacts/<artifact_path>` to upload an artifact to `artifact_path` (a relative path from the root artifact directory). """ validate_path_is_safe(artifact_path) head, tail = posixpath.split(artifact_path) w...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def list_artifacts(self, path=None): endpoint = "/mlflow-artifacts/artifacts" url, tail = self.artifact_uri.split(endpoint, maxsplit=1) root = tail.lstrip("/") params = {"path": posixpath.join(root, path) if path else root} host_creds = _get_default_host_creds(url) re...
0
Python
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
vulnerable
def _get_http_response_with_retries( method, url, max_retries, backoff_factor, backoff_jitter, retry_codes, raise_on_status=True, **kwargs, ): """ Performs an HTTP request using Python's `requests` module with an automatic retry policy. :param method: a string indicating the...
0
Python
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def test_log_artifact_gcp_with_headers( databricks_artifact_repo, test_file, artifact_path, expected_location ): expected_headers = {header.name: header.value for header in MOCK_HEADERS} mock_response = Response() mock_response.status_code = 200 mock_response.close = lambda: None mock_credential...
0
Python
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def test_log_artifact_aws_with_headers( databricks_artifact_repo, test_file, artifact_path, expected_location ): expected_headers = {header.name: header.value for header in MOCK_HEADERS} mock_response = Response() mock_response.status_code = 200 mock_response.close = lambda: None mock_credential...
0
Python
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def test_log_artifact_aws(databricks_artifact_repo, test_file, artifact_path, expected_location): mock_response = Response() mock_response.status_code = 200 mock_response.close = lambda: None mock_credential_info = ArtifactCredentialInfo( signed_uri=MOCK_AWS_SIGNED_URI, type=ArtifactCredentialTy...
0
Python
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def test_log_artifact_gcp(databricks_artifact_repo, test_file, artifact_path, expected_location): mock_response = Response() mock_response.status_code = 200 mock_response.close = lambda: None mock_credential_info = ArtifactCredentialInfo( signed_uri=MOCK_GCP_SIGNED_URL, type=ArtifactCredentialTy...
0
Python
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def run_as_real_user(args: list[str]) -> None: """Call subprocess.run as real user if called via sudo/pkexec. If we are called through pkexec/sudo, determine the real user ID and run the command with it to get the user's web browser settings. """ uid = _get_env_int("SUDO_UID", _get_env_int("PKEXEC_...
0
Python
CWE-269
Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
https://cwe.mitre.org/data/definitions/269.html
vulnerable
def open_url(self, url): """Open the given URL in a new browser window. Display an error dialog if everything fails. """ (r, w) = os.pipe() if os.fork() > 0: os.close(w) status = os.wait()[1] if status: title = _("Unable to...
0
Python
CWE-269
Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
https://cwe.mitre.org/data/definitions/269.html
vulnerable
def test_run_as_real_user_no_gvfsd( self, getpwuid_mock: unittest.mock.MagicMock ) -> None: """Test run_as_real_user() without no gvfsd process.""" getpwuid_mock.return_value = pwd.struct_passwd( ( "testuser", "x", 1337, ...
0
Python
CWE-269
Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
https://cwe.mitre.org/data/definitions/269.html
vulnerable
def test_run_as_real_user(self) -> None: """Test run_as_real_user() with SUDO_UID set.""" pwuid = pwd.getpwuid(int(os.environ["SUDO_UID"])) with tempfile.TemporaryDirectory() as tmpdir: # rename test program to fake gvfsd gvfsd_mock = os.path.join(tmpdir, "gvfsd") ...
0
Python
CWE-269
Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
https://cwe.mitre.org/data/definitions/269.html
vulnerable
def _get_data(self): LOG.debug("Machine is a Vultr instance") # Fetch metadata self.metadata = self.get_metadata() self.userdata_raw = self.metadata["user-data"] # Generate config and process data self.get_datasource_data(self.metadata) # Dump some data so...
0
Python
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
vulnerable
def redact_sensitive_keys(metadata, redact_value=REDACT_SENSITIVE_VALUE): """Redact any sensitive keys from to provided metadata dictionary. Replace any keys values listed in 'sensitive_keys' with redact_value. """ if not metadata.get("sensitive_keys", []): return metadata md_copy = copy.de...
0
Python
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
vulnerable
def process_instance_metadata(metadata, key_path="", sensitive_keys=()): """Process all instance metadata cleaning it up for persisting as json. Strip ci-b64 prefix and catalog any 'base64_encoded_keys' as a list @return Dict copy of processed metadata. """ md_copy = copy.deepcopy(metadata) ba...
0
Python
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
vulnerable
def _initialize_filesystem(self): util.ensure_dirs(self._initial_subdirs()) log_file = util.get_cfg_option_str(self.cfg, "def_log_file") if log_file: util.ensure_file(log_file, mode=0o640, preserve_mode=True) perms = self.cfg.get("syslog_fix_perms") if not...
0
Python
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
vulnerable
def test_existing_file_permissions_are_not_modified(self, init, tmpdir): """If the log file already exists, we should not modify its permissions See https://bugs.launchpad.net/cloud-init/+bug/1900837. """ # Use a mode that will never be made the default so this test will # a...
0
Python
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
vulnerable
def test_regular_user_cant_add_users(self): response = self.client.get("/admin/auth/user/add/") self.assertEqual(HTTPStatus.FORBIDDEN, response.status_code) response = self.client.post( "/admin/auth/user/add/", { "username": "added-by-regular-user", ...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def test_moderator_can_add_users(self): user_should_have_perm(self.moderator, "auth.add_user") user_should_have_perm(self.moderator, "auth.change_user") # test for https://github.com/kiwitcms/Kiwi/issues/642 self.client.login( # nosec:B106:hardcoded_password_funcarg use...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def test_superuser_can_add_users(self): # test for https://github.com/kiwitcms/Kiwi/issues/642 self.client.login( # nosec:B106:hardcoded_password_funcarg username=self.admin.username, password="admin-password" ) response = self.client.get("/admin/auth/user/add/") ...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def setUp(self): self.data = { "username": "test_user", "password1": "password", "password2": "password", "email": "new-tester@example.com", }
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def test_invalid_form(self): response = self.client.post( self.register_url, { "username": "kiwi-tester", "password1": "password-1", "password2": "password-2", "email": "new-tester@example.com", }, ...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def assert_user_registration(self, username, follow=False): with patch("tcms.kiwi_auth.models.secrets") as _secrets: _secrets.token_hex.return_value = self.fake_activate_key try: # https://github.com/mbi/django-simple-captcha/issues/84 # pylint: disab...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def test_register_user_already_registered(self): User.objects.create_user("kiwi-tester", "new-tester@example.com", "password") response = self.client.post( self.register_url, { "username": "test_user", "password1": "password", ...
0
Python
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
vulnerable
def test_send_mail_for_password_reset(self, mail_sent): user = User.objects.create_user("kiwi-tester", "tester@example.com", "password") user.is_active = True user.save() data = {"email": "tester@example.com"} response = self.client.post(self.password_reset_url, data, follow=...
0
Python
CWE-770
Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
def render_GET(self, request): template = env.get_template('generate_new.html') sites_len = len(get_all_canary_sites()) now = datetime.datetime.now() return template.render(settings=settings, sites_len=sites_len, now=now).encode('utf8')
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def get_signed_upload_url(path: str, download: bool = False) -> str: client = boto3.client( "s3", aws_access_key_id=settings.S3_KEY, aws_secret_access_key=settings.S3_SECRET_KEY, region_name=settings.S3_REGION, endpoint_url=settings.S3_ENDPOINT_URL, ) params = { ...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def check_xsend_links( name: str, name_str_for_test: str, content_disposition: str = "", download: bool = False, ) -> None: self.login("hamlet") fp = StringIO("zulip!") fp.name = name result = self.client_pos...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def test_avatar_url_local(self) -> None: self.login("hamlet") with get_test_image_file("img.png") as image_file: result = self.client_post("/json/users/me/avatar", {"file": image_file}) response_dict = self.assert_json_success(result) self.assertIn("avatar_url", response...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_local( request: HttpRequest, path_id: str, url_only: bool, download: bool = False ) -> HttpResponseBase: assert settings.LOCAL_FILES_DIR is not None local_path = os.path.join(settings.LOCAL_FILES_DIR, path_id) assert_is_local_storage_path("files", local_path) if not os.path.isfile(local_pa...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def get_local_file_path_id_from_token(token: str) -> Optional[str]: signer = TimestampSigner(salt=LOCAL_FILE_ACCESS_TOKEN_SALT) try: signed_data = base64.b16decode(token).decode() path_id = signer.unsign(signed_data, max_age=timedelta(seconds=60)) except (BadSignature, binascii.Error): ...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_local_avatar_unauthed(request: HttpRequest, path: str) -> HttpResponseBase: """Serves avatar images off disk, via nginx (or directly in dev), with no auth. This is done unauthed because these need to be accessed from HTML emails, where the client does not have any auth. We rely on the URL be...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_s3( request: HttpRequest, url_path: str, url_only: bool, download: bool = False ) -> HttpResponse: url = get_signed_upload_url(url_path, download=download) if url_only: return json_success(request, data=dict(url=url)) return redirect(url)
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_file( request: HttpRequest, maybe_user_profile: Union[UserProfile, AnonymousUser], realm_id_str: str, filename: str, url_only: bool = False, download: bool = False, ) -> HttpResponseBase: path_id = f"{realm_id_str}/{filename}" realm = get_valid_realm_from_request(request) i...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def generate_unauthed_file_access_url(path_id: str) -> str: signed_data = TimestampSigner(salt=LOCAL_FILE_ACCESS_TOKEN_SALT).sign(path_id) token = base64.b16encode(signed_data.encode()).decode() filename = path_id.split("/")[-1] return reverse("local_file_unauthed", args=[token, filename])
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_local_file_unauthed(request: HttpRequest, token: str, filename: str) -> HttpResponseBase: path_id = get_local_file_path_id_from_token(token) if path_id is None: raise JsonableError(_("Invalid token")) if path_id.split("/")[-1] != filename: raise JsonableError(_("Invalid filename"))...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def get_signed_upload_url(path: str) -> str: client = boto3.client( "s3", aws_access_key_id=settings.S3_KEY, aws_secret_access_key=settings.S3_SECRET_KEY, region_name=settings.S3_REGION, endpoint_url=settings.S3_ENDPOINT_URL, ) return client.generate_presigned_url( ...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_file_unauthed_from_token( request: HttpRequest, token: str, filename: str ) -> HttpResponseBase: path_id = get_file_path_id_from_token(token) if path_id is None: raise JsonableError(_("Invalid token")) if path_id.split("/")[-1] != filename: raise JsonableError(_("Invalid filena...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_local(request: HttpRequest, path_id: str, download: bool = False) -> HttpResponseBase: assert settings.LOCAL_FILES_DIR is not None local_path = os.path.join(settings.LOCAL_FILES_DIR, path_id) assert_is_local_storage_path("files", local_path) if not os.path.isfile(local_path): return Ht...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_file( request: HttpRequest, maybe_user_profile: Union[UserProfile, AnonymousUser], realm_id_str: str, filename: str, url_only: bool = False, download: bool = False, ) -> HttpResponseBase: path_id = f"{realm_id_str}/{filename}" realm = get_valid_realm_from_request(request) i...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_file_download_backend( request: HttpRequest, user_profile: UserProfile, realm_id_str: str, filename: str ) -> HttpResponseBase: return serve_file(request, user_profile, realm_id_str, filename, url_only=False, download=True)
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def serve_s3(request: HttpRequest, path_id: str, download: bool = False) -> HttpResponse: url = get_signed_upload_url(path_id) assert url.startswith("https://") if settings.DEVELOPMENT: # In development, we do not have the nginx server to offload # the response to; serve a redirect to the s...
0
Python
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
vulnerable
def get_permissions(self): if self.action == "create": self.permission_classes = [ IsRegistrationAllowed | FirstTimeSetupPermission | IsAdminUser ] elif self.action == "list": self.permission_classes = (AllowAny,) elif self.request.method =...
0
Python
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
async def form(self) -> FormMultiDict: """Retrieve form data from the request. If the request is either a 'multipart/form-data' or an 'application/x-www-form- urlencoded', return a FormMultiDict instance populated with the values sent in the request, otherwise, an empty instance. Re...
0
Python
CWE-770
Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
async def extract_multipart( connection: "Request[Any, Any]", ) -> Any: connection.scope["_form"] = form_values = ( # type: ignore[typeddict-item] connection.scope["_form"] # type: ignore[typeddict-item] if "_form" in connection.scope else parse_multipart_fo...
0
Python
CWE-770
Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
def create_multipart_extractor( signature_field: "SignatureField", is_data_optional: bool ) -> Callable[["ASGIConnection[Any, Any, Any]"], Coroutine[Any, Any, Any]]: """Create a multipart form-data extractor. Args: signature_field: A SignatureField instance. is_data_optional: Boolean dictat...
0
Python
CWE-770
Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
def nested_serializer_factory(relation_info, nested_depth): """ Return a NestedSerializer representation of a serializer field. This method should only be called in build_nested_field() in which relation_info and nested_depth are already given. """ nested_serializer_name = f"Nested{nested_depth}...
0
Python
CWE-312
Cleartext Storage of Sensitive Information
The product stores sensitive information in cleartext within a resource that might be accessible to another control sphere.
https://cwe.mitre.org/data/definitions/312.html
vulnerable
def render(self, record, bound_column, value): # pylint: disable=arguments-differ if value: name = bound_column.name css_class = getattr(record, f"get_{name}_class")() label = getattr(record, f"get_{name}_display")() return mark_safe(f'<span class="label labe...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def render(self, value): return mark_safe(f'<span class="label color-block" style="background-color: #{value}">&nbsp;</span>')
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def render(self, record, value): # pylint: disable=arguments-differ if value: url = reverse(self.viewname, kwargs=self.view_kwargs) if self.url_params: url += "?" + "&".join([f"{k}={getattr(record, v)}" for k, v in self.url_params.items()]) return mark_sa...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def header(self): return mark_safe('<input type="checkbox" class="toggle" title="Toggle all" />')
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def add_html_id(element_str, id_str): """Add an HTML `id="..."` attribute to the given HTML element string. Args: element_str (str): String describing an HTML element. id_str (str): String to add as the `id` attribute of the element_str. Returns: (str): HTML string with added `id`....
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def render_boolean(value): """Render HTML from a computed boolean value. Args: value (any): Input value, can be any variable. A truthy value (for example non-empty string / True / non-zero number) is considered True. A falsey value other than None (for example "" or 0 or False) ...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def render_markdown(value): """ Render text as Markdown Example: {{ text | render_markdown }} """ # Strip HTML tags value = strip_tags(value) # Sanitize Markdown links schemes = "|".join(settings.ALLOWED_URL_SCHEMES) pattern = rf"\[(.+)\]\((?!({schemes})).*:(.+)\)" valu...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def placeholder(value): """Render a muted placeholder if value is falsey, else render the value. Args: value (any): Input value, can be any variable. Returns: (str): Placeholder in HTML, or the string representation of the value. Example: >>> placeholder("") '<span cla...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def render_jinja2(template_code, context): """ Render a Jinja2 template with the provided context. Return the rendered content. """ rendering_engine = engines["jinja"] template = rendering_engine.from_string(template_code) return template.render(context=context)
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def successful_post(self, request, obj, created, logger): """Callback after the form is successfully saved but before redirecting the user.""" verb = "Created" if created else "Modified" msg = f"{verb} {self.queryset.model._meta.verbose_name}" logger.info(f"{msg} {obj} (PK: {obj.pk})...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def filter_queryset(self, queryset): """ Filter a query with request querystrings. """ if self.filterset_class is not None: self.filter_params = self.get_filter_params(self.request) self.filterset = self.filterset_class(self.filter_params, queryset) ...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def _process_create_or_update_form(self, form): """ Helper method to create or update an object after the form is validated successfully. """ request = self.request queryset = self.get_queryset() with transaction.atomic(): object_created = not form.instanc...
0
Python
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable