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_create_custom_connector_template(
self,
db: Session,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
) -> None:
template = CustomConnectorTemplate(
key="planet_express",
name="P... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_create_custom_connector_template(
self,
db: Session,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
) -> None:
template = CustomConnectorTemplate(
key="planet_express",
name="P... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = ... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = ... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_no_templates(self):
CONFIG.security.allow_custom_connector_functions = True
connector_templates = CustomConnectorTemplateLoader.get_connector_templates()
assert connector_templates == {} | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_no_templates(self):
CONFIG.security.allow_custom_connector_functions = True
connector_templates = CustomConnectorTemplateLoader.get_connector_templates()
assert connector_templates == {} | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_save_template(
self,
mock_create_or_update: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
db = MagicMock()
CustomConnectorTemplateLoader.save_template(
... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_save_template(
self,
mock_create_or_update: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
db = MagicMock()
CustomConnectorTemplateLoader.save_template(
... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_function_loader(self):
"""Verify that all override implementations can be loaded by RestrictedPython"""
overrides_path = "src/fides/api/service/saas_request/override_implementations"
for filename in os.listdir(overrides_path):
if filename.endswith(".py") and filename !... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_function_loader(self):
"""Verify that all override implementations can be loaded by RestrictedPython"""
overrides_path = "src/fides/api/service/saas_request/override_implementations"
for filename in os.listdir(overrides_path):
if filename.endswith(".py") and filename !... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_loaders_have_separate_instances(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = [... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_loaders_have_separate_instances(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = [... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_disallowed_modules(
self,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
CONFIG.security.allow_custom_connector_functions = True
with pytest.raises(SyntaxError) as exc:
CustomConnectorT... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_disallowed_modules(
self,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
CONFIG.security.allow_custom_connector_functions = True
with pytest.raises(SyntaxError) as exc:
CustomConnectorT... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def replaceable_planet_express_zip(
self,
replaceable_planet_express_config,
planet_express_dataset,
planet_express_functions,
planet_express_icon,
) -> BytesIO:
return create_zip_file(
{
"config.yml": replaceable_planet_express_config,... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def replaceable_planet_express_zip(
self,
replaceable_planet_express_config,
planet_express_dataset,
planet_express_functions,
planet_express_icon,
) -> BytesIO:
return create_zip_file(
{
"config.yml": replaceable_planet_express_config,... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_invalid_template(
self,
mock_all: MagicMock,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = [
... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_invalid_template(
self,
mock_all: MagicMock,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = True
mock_all.return_value = [
... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_custom_connector_functions_disabled_custom_functions(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
"""
A connector template with no custom functions should still... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_custom_connector_functions_disabled_custom_functions(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
"""
A connector template with no custom functions should still... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_invalid_functions(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
CONFIG.security.allow_custom_connector_functions = True
# save custom connector template to the ... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_invalid_functions(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
):
CONFIG.security.allow_custom_connector_functions = True
# save custom connector template to the ... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def test_custom_connector_template_loader_custom_connector_functions_disabled(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = Fa... | 0 | Python | CWE-693 | Protection Mechanism Failure | The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. | https://cwe.mitre.org/data/definitions/693.html | vulnerable |
def test_custom_connector_template_loader_custom_connector_functions_disabled(
self,
mock_all: MagicMock,
planet_express_config,
planet_express_dataset,
planet_express_icon,
planet_express_functions,
):
CONFIG.security.allow_custom_connector_functions = Fa... | 0 | Python | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
def __init__(
self,
privacy_request: PrivacyRequest,
dsr_data: Dict[str, Any],
):
"""
Manages populating HTML templates from the given data and adding the generated
pages to a zip file in a way that the pages can be navigated between.
"""
# zip fi... | 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 _populate_template(
self,
template_path: str,
heading: Optional[str] = None,
description: Optional[str] = None,
data: Optional[Dict[str, Any]] = None,
) -> str:
"""Generates a file from the template and data"""
report_data = {
"heading": he... | 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 safer_getattr(object, name, default=None, getattr=getattr):
"""Getattr implementation which prevents using format on string objects.
format() is considered harmful:
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
"""
if isinstance(object, str) and name == 'format':
raise No... | 0 | Python | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | vulnerable |
def test_string_in_utility_builtins():
from RestrictedPython.Utilities import utility_builtins
assert utility_builtins['string'] is string | 0 | Python | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | vulnerable |
def test_Guards__safer_getattr__1():
"""It prevents using the format method of a string.
format() is considered harmful:
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
"""
glb = {
'__builtins__': safe_builtins,
}
with pytest.raises(NotImplementedError) as err:
r... | 0 | Python | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | vulnerable |
def test_Guards__safer_getattr__2():
"""It prevents using the format method of a unicode.
format() is considered harmful:
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
"""
glb = {
'__builtins__': safe_builtins,
}
with pytest.raises(NotImplementedError) as err:
... | 0 | Python | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | vulnerable |
def test_conn_upgrade(parser) -> None:
text = (
b"GET /test HTTP/1.1\r\n"
b"connection: upgrade\r\n"
b"upgrade: websocket\r\n\r\n"
)
messages, upgrade, tail = parser.feed_data(text)
msg = messages[0][0]
assert not msg.should_close
assert msg.upgrade
assert upgrade | 0 | Python | CWE-444 | Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling') | The product acts as an intermediary HTTP agent
(such as a proxy or firewall) in the data flow between two
entities such as a client and server, but it does not
interpret malformed HTTP requests or responses in ways that
are consistent with how the messages will be processed by
... | https://cwe.mitre.org/data/definitions/444.html | vulnerable |
def set_k304(self) -> bool:
ck = gencookie("k304", self.uparam["k304"], self.args.R, False, 86400 * 299)
self.out_headerlist.append(("Set-Cookie", ck))
self.redirect("", "?h#cc")
return True | 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 |
fn invalid_feature_names_error() {
// Errors for more restricted feature syntax.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[features]
"foo/bar" = []
... | 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 run_command(cmd, log_output=False):
"""
Return (exitcode, output) of executing the provided `cmd` in a shell.
`cmd` can be provided as a string or as a list of arguments.
If `log_output` is True, the stdout and stderr of the process will be captured
and streamed to the `logger`.
"""
if ... | 0 | Python | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
def _redirect_safe(self, url, default=None):
"""Redirect if url is on our PATH
Full-domain redirects are allowed if they pass our CORS origin checks.
Otherwise use default (self.base_url if unspecified).
"""
if default is None:
default = self.base_url
# ... | 0 | Python | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
def write_error(self, status_code: int, **kwargs: Any) -> None:
"""APIHandler errors are JSON, not human pages"""
self.set_header("Content-Type", "application/json")
message = responses.get(status_code, "Unknown HTTP Error")
reply: dict[str, Any] = {
"message": message,
... | 0 | Python | CWE-209 | Generation of Error Message Containing Sensitive Information | The product generates an error message that includes sensitive information about its environment, users, or associated data. | https://cwe.mitre.org/data/definitions/209.html | vulnerable |
async def post(self, kernel_id, action):
"""Interrupt or restart a kernel."""
km = self.kernel_manager
if action == "interrupt":
await ensure_async(km.interrupt_kernel(kernel_id)) # type:ignore[func-returns-value]
self.set_status(204)
if action == "restart":
... | 0 | Python | CWE-209 | Generation of Error Message Containing Sensitive Information | The product generates an error message that includes sensitive information about its environment, users, or associated data. | https://cwe.mitre.org/data/definitions/209.html | vulnerable |
def _create_token(cls, user_id: Optional[str], issued_on: float) -> str:
"""Creates a new CSRF token.
Args:
user_id: str|None. The user_id for which the token is generated.
issued_on: float. The timestamp at which the token was issued.
Returns:
str. The ... | 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 is_csrf_token_valid(cls, user_id: Optional[str], token: str) -> bool:
"""Validates a given CSRF token.
Args:
user_id: str|None. The user_id to validate the CSRF token against.
token: str. The CSRF token to validate.
Returns:
bool. Whether the given C... | 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_create_and_validate_token(self) -> None:
uid = 'user_id'
token = base.CsrfTokenManager.create_csrf_token(uid)
self.assertTrue(base.CsrfTokenManager.is_csrf_token_valid(
uid, token))
self.assertFalse(
base.CsrfTokenManager.is_csrf_token_valid('bad_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 _secure_path(path_tuple):
if _has_insecure_pathelement(path_tuple):
# belt-and-suspenders security; this should never be true
# unless someone screws up the traversal_path code
# (request.subpath is computed via traversal_path too)
return None
if any([_contains_slash(item) fo... | 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 _contains_slash(item):
for sep in _seps:
if sep in item:
return True | 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 get_all_progress(self, recency=_progress_period_secs * 2):
"""
Get progress information for all ongoing operations
:param recency: (int) seconds back
:return list of progress codes
"""
query = """
SELECT code, array_agg(state) FROM web_progress
WHE... | 0 | Python | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | vulnerable |
def handle_one_response(self):
"""
Invoke the application to produce one response.
This is called by :meth:`handle_one_request` after all the
state for the request has been established. It is responsible
for error handling.
"""
self.time_start = time.time()
... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
def _handle_client_error(self, ex):
# Called for invalid client input
# Returns the appropriate error response.
if not isinstance(ex, ValueError):
# XXX: Why not self._log_error to send it through the loop's
# handle_error method?
traceback.print_exc()
... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
def _chunked_read(self, length=None, use_readline=False):
# pylint:disable=too-many-branches
rfile = self.rfile
self._send_100_continue()
if length == 0:
return b""
if use_readline:
reader = self.rfile.readline
else:
reader = self... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
def __new__(cls, classname, bases, classDict):
# pylint and pep8 fight over what this should be called (mcs or cls).
# pylint gets it right, but we cant scope disable pep8, so we go with
# its convention.
# pylint: disable=bad-mcs-classmethod-argument
timeout = classDict.get(... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
async def login(cls, username: str, password: str) -> t.Optional[int]:
"""
Make sure the user exists and the password is valid. If so, the
``last_login`` value is updated in the database.
:returns:
The id of the user if a match is found, otherwise ``None``.
"""
... | 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 send_mail_async(*args, **kwargs):
""" Using celery to send email async
You can use it as django send_mail function
Example:
send_mail_sync.delay(subject, message, from_mail, recipient_list, fail_silently=False, html_message=None)
Also, you can ignore the from_mail, unlike django send_mail, fr... | 0 | Python | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
def send_mail_attachment_async(subject, message, recipient_list, attachment_list=None):
if attachment_list is None:
attachment_list = []
from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER
subject = (settings.EMAIL_SUBJECT_PREFIX or '') + subject
recipient_list = [mail for mail in recip... | 0 | Python | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
def test_retry_set_remove_headers_on_redirect(self) -> None:
retry = Retry(remove_headers_on_redirect=["X-API-Secret"])
assert list(retry.remove_headers_on_redirect) == ["x-api-secret"] | 0 | Python | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def test_retry_default_remove_headers_on_redirect(self) -> None:
retry = Retry()
assert list(retry.remove_headers_on_redirect) == ["authorization"] | 0 | Python | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def test_redirect_cross_host_set_removed_headers(self) -> None:
with PoolManager() as http:
r = http.request(
"GET",
f"{self.base_url}/redirect",
fields={"target": f"{self.base_url_alt}/headers"},
headers={"X-API-Secret": "foo", "Au... | 0 | Python | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def test_redirect_cross_host_no_remove_headers(self) -> None:
with PoolManager() as http:
r = http.request(
"GET",
f"{self.base_url}/redirect",
fields={"target": f"{self.base_url_alt}/headers"},
headers={"Authorization": "foo"},
... | 0 | Python | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def test_redirect_cross_host_remove_headers(self) -> None:
with PoolManager() as http:
r = http.request(
"GET",
f"{self.base_url}/redirect",
fields={"target": f"{self.base_url_alt}/headers"},
headers={"Authorization": "foo"},
... | 0 | Python | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def test_basic_metric_success(self):
self.client.get("/hello/756")
expected_duration_attributes = {
"http.method": "GET",
"http.host": "localhost",
"http.scheme": "http",
"http.flavor": "1.1",
"http.server_name": "localhost",
"n... | 0 | Python | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
def get_default_span_name(environ):
"""
Default span name is the HTTP method and URL path, or just the method.
https://github.com/open-telemetry/opentelemetry-specification/pull/3165
https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#name
Args:
environ: T... | 0 | Python | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
def collect_request_attributes(environ):
"""Collects HTTP request attributes from the PEP3333-conforming
WSGI environ and returns a dictionary to be used as span creation attributes.
"""
result = {
SpanAttributes.HTTP_METHOD: environ.get("REQUEST_METHOD"),
SpanAttributes.HTTP_SERVER_NAM... | 0 | Python | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
def time_dataframe():
try:
from pandas._testing import makeTimeDataFrame
return makeTimeDataFrame(), None
except ImportError:
from pandas.util.testing import makeTimeDataFrame
return makeTimeDataFrame(), None | 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 _clone(
self,
src: DictionaryObject,
pdf_dest: PdfWriterProtocol,
force_duplicate: bool,
ignore_fields: Optional[Sequence[Union[str, int]]],
) -> None:
"""
Update the object from src.
Args:
src:
pdf_dest:
fo... | 0 | Python | CWE-835 | Loop with Unreachable Exit Condition ('Infinite Loop') | The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | https://cwe.mitre.org/data/definitions/835.html | vulnerable |
def clone(
self,
pdf_dest: PdfWriterProtocol,
force_duplicate: bool = False,
ignore_fields: Optional[Sequence[Union[str, int]]] = (),
) -> "DictionaryObject":
"""Clone object into pdf_dest."""
try:
if self.indirect_reference.pdf == pdf_dest and not for... | 0 | Python | CWE-835 | Loop with Unreachable Exit Condition ('Infinite Loop') | The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | https://cwe.mitre.org/data/definitions/835.html | vulnerable |
def clone(
self,
pdf_dest: Any,
force_duplicate: bool = False,
ignore_fields: Optional[Sequence[Union[str, int]]] = (),
) -> "ContentStream":
"""
Clone object into pdf_dest.
Args:
pdf_dest:
force_duplicate:
ignore_field... | 0 | Python | CWE-835 | Loop with Unreachable Exit Condition ('Infinite Loop') | The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | https://cwe.mitre.org/data/definitions/835.html | vulnerable |
def test_slack_webhook(request):
"""Test webhook."""
try:
body = json.loads(request.body)
except (TypeError, json.decoder.JSONDecodeError):
return JsonResponse({"error": "Cannot parse request body"}, status=400)
webhook = body.get("webhook")
if not webhook:
return JsonRespo... | 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 main() -> None:
try:
run(sys.argv)
except KeyboardInterrupt:
pass
except (OSError, TypeError, ValueError) as e:
print(f"Error: {e}", file=sys.stderr) # noqa: T201
sys.exit(1) | 0 | Python | CWE-674 | Uncontrolled Recursion | The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. | https://cwe.mitre.org/data/definitions/674.html | vulnerable |
def __init__(self, width):
self._width = width
pa.PyExtensionType.__init__(self, pa.binary(width)) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def check_export_import_schema(schema_factory):
c_schema = ffi.new("struct ArrowSchema*")
ptr_schema = int(ffi.cast("uintptr_t", c_schema))
gc.collect() # Make sure no Arrow data dangles in a ref cycle
old_allocated = pa.total_allocated_bytes()
schema_factory()._export_to_c(ptr_schema)
assert... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_export_import_batch_with_extension():
check_export_import_batch(make_extension_batch) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_export_import_schema_with_extension():
check_export_import_schema(make_extension_schema) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __reduce__(self):
return ParamExtType, (self.width,) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __init__(self, width):
self._width = width
pa.PyExtensionType.__init__(self, pa.binary(width)) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_parquet_extension_with_nested_storage(tmpdir):
# Parquet support for extension types with nested storage type
import pyarrow.parquet as pq
struct_array = pa.StructArray.from_arrays(
[pa.array([0, 1], type="int64"), pa.array([4, 5], type="int64")],
names=["left", "right"])
list_... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __init__(self):
pa.PyExtensionType.__init__(self, pa.int8()) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_parquet_extension_nested_in_extension(tmpdir):
# Parquet support for extension<list<extension>>
import pyarrow.parquet as pq
inner_ext_type = IntegerType()
inner_storage = pa.array([4, 5, 6, 7], type=pa.int64())
inner_ext_array = pa.ExtensionArray.from_storage(inner_ext_type,
... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_uuid_type_pickle(pickle_module):
for proto in range(0, pickle_module.HIGHEST_PROTOCOL + 1):
ty = UuidType()
ser = pickle_module.dumps(ty, protocol=proto)
del ty
ty = pickle_module.loads(ser)
wr = weakref.ref(ty)
assert ty.extension_name == "arrow.py_extension... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_ext_type_basics():
ty = UuidType()
assert ty.extension_name == "arrow.py_extension_type" | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_ipc():
batch = example_batch()
buf = ipc_write_batch(batch)
del batch
batch = ipc_read_batch(buf)
arr = check_example_batch(batch)
assert arr.type == ParamExtType(3) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __init__(self, storage_type, annotation):
self.annotation = annotation
super().__init__(storage_type) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_parquet_nested_extension(tmpdir):
# Parquet support for extension types nested in struct or list
import pyarrow.parquet as pq
ext_type = IntegerType()
storage = pa.array([4, 5, 6, 7], type=pa.int64())
ext_array = pa.ExtensionArray.from_storage(ext_type, storage)
# Struct of extensions... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_ext_type_str():
ty = IntegerType()
expected = "extension<arrow.py_extension_type<IntegerType>>"
assert str(ty) == expected
assert pa.DataType.__str__(ty) == expected | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_ipc_unknown_type():
batch = example_batch()
buf = ipc_write_batch(batch)
del batch
orig_type = ParamExtType
try:
# Simulate the original Python type being unavailable.
# Deserialization should not fail but return a placeholder type.
del globals()['ParamExtType']
... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def check_example_batch(batch):
arr = batch.column(0)
assert isinstance(arr, pa.ExtensionArray)
assert arr.type.storage_type == pa.binary(3)
assert arr.storage.to_pylist() == [b"foo", b"bar"]
return arr | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __reduce__(self):
return TinyIntType, () | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __init__(self, storage_type):
pa.PyExtensionType.__init__(self, storage_type) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def test_cast_between_extension_types():
array = pa.array([1, 2, 3], pa.int8())
tiny_int_arr = array.cast(TinyIntType())
assert tiny_int_arr.type == TinyIntType()
# Casting between extension types w/ different storage types not okay.
msg = ("Casting from 'extension<arrow.py_extension_type<TinyIntT... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __init__(self):
pa.PyExtensionType.__init__(self, pa.int64()) | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def __reduce__(self):
return DummyExtensionType, () | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
def check_soa_record(target: str) -> bool:
"""Checks the presence of a SOA record for the Email Systems Testing."""
result = False
try:
answers = dns.resolver.query(target, "SOA")
result = 0 != len(answers)
except Exception:
result = False
return result | 0 | Python | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
def full_domain_validator(hostname):
"""
Fully validates a domain name as compilant with the standard rules:
- Composed of series of labels concatenated with dots, as are all domain names.
- Each label must be between 1 and 63 characters long.
- The entire hostname (including the delimit... | 0 | Python | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
def post_process_findings(banner: Optional[Banner], algs: Algorithms) -> List[str]:
'''Perform post-processing on scan results before reporting them to the user. Returns a list of algorithms that should not be recommended'''
algorithm_recommendation_suppress_list = []
# If the server is OpenSSH, and the... | 0 | Python | CWE-354 | Improper Validation of Integrity Check Value | The product does not validate or incorrectly validates the integrity check values or "checksums" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission. | https://cwe.mitre.org/data/definitions/354.html | vulnerable |
def test_ssh2_server_simple(self, output_spy, virtual_socket):
vsocket = virtual_socket
w = self.wbuf()
w.write_byte(self.protocol.MSG_KEXINIT)
w.write(self._kex_payload())
vsocket.rdata.append(b'SSH-2.0-OpenSSH_7.3 ssh-audit-test\r\n')
vsocket.rdata.append(self._crea... | 0 | Python | CWE-354 | Improper Validation of Integrity Check Value | The product does not validate or incorrectly validates the integrity check values or "checksums" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission. | https://cwe.mitre.org/data/definitions/354.html | vulnerable |
def process_file():
content = request.json
target_filename = content.get('filename')
print(f"Processing {target_filename}")
success, reason = process_single(WATCH_DIRECTORY, target_filename)
return json.dumps({'filename': target_filename, 'success': success, 'reason': reason}) | 0 | Python | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
def _load_pkcs7_certificates(self, p7) -> typing.List[x509.Certificate]:
nid = self._lib.OBJ_obj2nid(p7.type)
self.openssl_assert(nid != self._lib.NID_undef)
if nid != self._lib.NID_pkcs7_signed:
raise UnsupportedAlgorithm(
"Only basic signed structures are curren... | 0 | Python | CWE-476 | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | https://cwe.mitre.org/data/definitions/476.html | vulnerable |
def handler500(request, template_name="dpaste/500.html"):
context = {}
context.update(config.extra_template_context)
response = render(request, template_name, context, status=500)
add_never_cache_headers(response)
return response | 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 loginForm(request, next=''):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = Login_Form(request.POST)
# check whether it's valid:
if form.is_valid():
... | 0 | Python | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
def loginForm(request, next=''):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = Login_Form(request.POST)
# check whether it's valid:
if form.is_valid():
... | 0 | Python | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
def loginForm(request, next=''):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = Login_Form(request.POST)
# check whether it's valid:
if form.is_valid():
... | 0 | Python | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
def LoadSettingsFile(filename=SETTINGS_FILE):
"""Loads settings file in yaml format given file name.
:param filename: path for settings file. 'settings.yaml' by default.
:type filename: str.
:raises: SettingsError
"""
try:
with open(filename) as stream:
data = load(stream, L... | 0 | Python | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
async def get(self, request: web.Request) -> web.Response:
"""Return a list of persons if request comes from a local IP."""
try:
remote_address = ip_address(request.remote) # type: ignore[arg-type]
except ValueError:
return self.json_message(
message=... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
async def _test_fetch_auth_providers_home_assistant(
hass: HomeAssistant,
aiohttp_client: ClientSessionGenerator,
ip: str,
additional_expected_fn: Callable[[User], dict[str, Any]],
) -> None:
"""Test fetching auth providers for homeassistant auth provider."""
client = await async_setup_auth(
... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
async def test_fetch_auth_providers_home_assistant_person_loaded(
hass: HomeAssistant,
aiohttp_client: ClientSessionGenerator,
ip: str,
is_local: bool,
) -> None:
"""Test fetching auth providers for homeassistant auth provider, where person integration is loaded."""
domain = "person"
config ... | 0 | Python | NVD-CWE-noinfo | null | null | null | vulnerable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.