Skip to content

Commit

Permalink
chore(iast): disable error log metric (#10803)
Browse files Browse the repository at this point in the history
Disable the "Tainted Map isn't initialized" error log metric. This
message is triggered when taint occurs outside the request, making it
redundant.

No release note is required, as this error occurs after PR #10740, which
has not been released yet.

Task APPSEC-55018

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit 99428de)
  • Loading branch information
avara1986 authored and github-actions[bot] committed Sep 26, 2024
1 parent 8ae4244 commit 3fd4b2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ddtrace/appsec/_iast/_taint_tracking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def taint_pyobject(pyobject: Any, source_name: Any, source_value: Any, source_or
_set_metric_iast_executed_source(source_origin)
return pyobject_newid
except ValueError as e:
iast_taint_log_error("Tainting object error (pyobject type %s): %s" % (type(pyobject), e))
log.debug("Tainting object error (pyobject type %s): %s", type(pyobject), e)
return pyobject


Expand Down
8 changes: 4 additions & 4 deletions tests/appsec/iast/aspects/test_add_aspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ def test_add_aspect_tainting_add_left_twice(obj1, obj2):
@pytest.mark.parametrize(
"log_level, iast_debug, expected_log_msg",
[
(logging.DEBUG, "", ""),
(logging.DEBUG, "", "Tainting object error"),
(logging.WARNING, "", ""),
(logging.DEBUG, "false", ""),
(logging.DEBUG, "false", "Tainting object error"),
(logging.WARNING, "false", ""),
(logging.DEBUG, "true", "_iast/_taint_tracking/__init__.py"),
(logging.DEBUG, "true", "Tainting object error"),
(logging.WARNING, "true", ""),
],
)
Expand Down Expand Up @@ -271,7 +271,7 @@ def test_taint_object_error_with_no_context(log_level, iast_debug, expected_log_
assert len(ranges_result) == 0

if expected_log_msg:
assert any(expected_log_msg in record.message for record in caplog.records), [
assert any(record.message.startswith(expected_log_msg) for record in caplog.records), [
record.message for record in caplog.records
]
else:
Expand Down

0 comments on commit 3fd4b2a

Please sign in to comment.