Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid the use of hardcoded temporary directory names in framework #10115

Closed
13 tasks done
Tracked by #2330
mcarmona99 opened this issue Sep 14, 2021 · 1 comment · Fixed by #10544
Closed
13 tasks done
Tracked by #2330

Avoid the use of hardcoded temporary directory names in framework #10115

mcarmona99 opened this issue Sep 14, 2021 · 1 comment · Fixed by #10544
Assignees

Comments

@mcarmona99
Copy link
Contributor

mcarmona99 commented Sep 14, 2021

Description

With the test created in the issue wazuh/wazuh-qa#1615, some possible code flaws were found by Bandit.

In this issue we specify flaws regarding the use of insecure usage of temp file/directory.

Vulnerabilities found in:

  • framework/wazuh/core/configuration.py line 676
  • framework/wazuh/core/utils.py line 1755

These flaws are caused by hardcoded temporary directories. We could investigate if we could generate a temporary one in a safer way (the tmpfile library can create it by its own): https://docs.openstack.org/bandit/1.4.0/plugins/hardcoded_tmp_directory.html

Once changes are done, pass the test to check that these flaws were deleted from the known flaws JSON file of framework.

Checks

wazuh/wazuh

  • Unit tests without failures. Updated and/or expanded if there are new functions/methods/outputs:
    • Cluster (framework/wazuh/core/cluster/tests/ & framework/wazuh/core/cluster/dapi/tests/)
    • Core (framework/wazuh/core/tests/)
    • SDK (framework/wazuh/tests/)
    • RBAC (framework/wazuh/rbac/tests/)
    • API (api/api/tests/)
  • API tavern integration tests without failures. Updated and/or expanded if needed (api/test/integration/):
    • Affected tests
    • Affected RBAC (black and white) tests
  • Review integration test mapping using the script (api/test/integration/mapping/integration_test_api_endpoints.json)
  • Review of spec.yaml examples and schemas (api/api/spec/spec.yaml)
  • Review exceptions remediation when any endpoint path changes or is removed (framework/wazuh/core/exception.py)
  • Changelog (CHANGELOG.md)

wazuh/wazuh-documentation

  • Migration from 3.X for changed endpoints (source/user-manual/api/equivalence.rst)
  • Update RBAC reference with new/modified actions/resources/relationships (source/user-manual/api/rbac/reference.rst)
@Kondent
Copy link
Contributor

Kondent commented Oct 14, 2021

Update

I found out a solution using NamedTemporaryFile from tempfile package.
I'll need to do more tests but it seems to be properly working. Bandit is no longer alerting of this flaw at our code.

Regards,
Alexis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
4 participants