Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/codeaudit/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
Function to create nice APIs. So API helper functions.
"""

import pandas as pd

from codeaudit.api_interfaces import get_modules, get_overview, _build_weakness_details
from codeaudit.api_interfaces import _build_weakness_details, get_modules, get_overview
from codeaudit.checkmodules import get_all_modules
from codeaudit.filehelpfunctions import (
collect_python_source_files,
Expand Down
6 changes: 2 additions & 4 deletions src/codeaudit/api_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
"""

import datetime
import json
import html
import json
import platform
from collections import Counter
from pathlib import Path
from importlib.metadata import version
from pathlib import Path

import altair as alt
import pandas as pd


from codeaudit.checkmodules import (
check_module_vulnerability,
get_all_modules,
Expand Down
2 changes: 1 addition & 1 deletion src/codeaudit/filehelpfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def is_ast_parsable(file_path):
warnings.simplefilter("ignore", category=SyntaxWarning)
ast.parse(source, filename=file_path)
return True
except (SyntaxError, UnicodeDecodeError, ValueError) as e:
except (SyntaxError, UnicodeDecodeError, ValueError):
return False


Expand Down
3 changes: 1 addition & 2 deletions src/codeaudit/privacy_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import ast
import datetime
import re
from importlib.resources import files
from importlib.metadata import version
from importlib.resources import files
from pathlib import Path


from codeaudit.filehelpfunctions import (
collect_python_source_files,
get_filename_from_path,
Expand Down
3 changes: 1 addition & 2 deletions src/codeaudit/pypi_package_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import tarfile
import tempfile
import zlib
from importlib.metadata import version
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

from importlib.metadata import version

CA_VERSION = version("codeaudit")

NOCX_HEADERS = {
Expand Down
43 changes: 20 additions & 23 deletions src/codeaudit/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,43 @@
Reporting functions for codeaudit
"""

import re
import datetime
import html
import os
from pathlib import Path
import re
import sys

from importlib.metadata import version
from importlib.resources import files
from pathlib import Path

import pandas as pd
import html
import datetime

from codeaudit.security_checks import perform_validations, ast_security_checks
from codeaudit.altairplots import multi_bar_chart
from codeaudit.api_interfaces import _collect_issue_lines
from codeaudit.checkmodules import (
check_module_vulnerability,
get_all_modules,
get_imported_modules,
get_imported_modules_by_file,
)
from codeaudit.filehelpfunctions import (
get_filename_from_path,
collect_python_source_files,
read_in_source_file,
get_filename_from_path,
has_python_files,
is_ast_parsable,
read_in_source_file,
)
from codeaudit.altairplots import multi_bar_chart
from codeaudit.htmlhelpfunctions import dict_list_to_html_table, json_to_html
from codeaudit.privacy_lint import data_egress_scan, has_privacy_findings
from codeaudit.pypi_package_scan import get_package_source, get_pypi_download_info
from codeaudit.security_checks import ast_security_checks, perform_validations
from codeaudit.suppression import filter_sast_results
from codeaudit.totals import (
get_statistics,
overview_count,
overview_per_file,
total_modules,
)
from codeaudit.checkmodules import (
get_imported_modules,
check_module_vulnerability,
get_all_modules,
get_imported_modules_by_file,
)
from codeaudit.htmlhelpfunctions import json_to_html, dict_list_to_html_table

from codeaudit.pypi_package_scan import get_pypi_download_info, get_package_source
from codeaudit.privacy_lint import data_egress_scan, has_privacy_findings
from codeaudit.suppression import filter_sast_results
from codeaudit.api_interfaces import _collect_issue_lines

from importlib.resources import files

CA_VERSION = version("codeaudit")

Expand Down
2 changes: 0 additions & 2 deletions src/dashboard/dashboardapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
weaknesses_radial_overview,
)
from codeaudit.api_helpers import _codeaudit_directory_scan_wasm

from codeaudit.api_interfaces import get_package_source, version_info

from codeaudit.dashboard_reports import (
create_statistics_overview,
get_disclaimer_text,
Expand Down
1 change: 0 additions & 1 deletion tests/count_lines_file1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ def example():
x = {"a": 1, "b": 2}

maikel = you # comment
mystring = "See how this is detected!"
return x
6 changes: 1 addition & 5 deletions tests/test_apicalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

import pytest
from pathlib import Path

from codeaudit.api_interfaces import version_info, get_overview

from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.checkmodules import get_imported_modules
from codeaudit.api_interfaces import get_overview, version_info


def test_api_version():
Expand Down
1 change: 0 additions & 1 deletion tests/test_basicpatterns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
1 change: 0 additions & 1 deletion tests/test_chmod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.security_checks import perform_validations
Expand Down
3 changes: 0 additions & 3 deletions tests/test_constructspart2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.issuevalidations import find_constructs
from codeaudit.security_checks import perform_validations

# constructs are tested in this test file based on SAST checks defined , not running constructs directly for testing as in other test files.
Expand Down
1 change: 0 additions & 1 deletion tests/test_correctexceptionuse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
2 changes: 0 additions & 2 deletions tests/test_count_commentlines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pytest

from codeaudit.totals import count_comment_lines


Expand Down
1 change: 0 additions & 1 deletion tests/test_directorycreation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
1 change: 0 additions & 1 deletion tests/test_directorycreation2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
1 change: 0 additions & 1 deletion tests/test_edgecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
Validation file to see if SAST suppression works correct.
"""

import pytest
from pathlib import Path

from codeaudit.security_checks import perform_validations
Expand Down
1 change: 0 additions & 1 deletion tests/test_hashstrenght.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
3 changes: 1 addition & 2 deletions tests/test_modulecheck.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pytest
from pathlib import Path

from codeaudit.checkmodules import check_module_vulnerability, get_imported_modules
from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.checkmodules import get_imported_modules, check_module_vulnerability


def test_module_check():
Expand Down
3 changes: 0 additions & 3 deletions tests/test_obfuscatingbuiltins.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.issuevalidations import find_constructs
from codeaudit.security_checks import perform_validations

# constructs are tested in this test file based on SAST checks defined , not running constructs directly for testing as in other test files.
Expand Down
1 change: 0 additions & 1 deletion tests/test_oschecks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2025-present Maikel Mardjan(https://nocomplexity.com/) and all contributors!
#
# SPDX-License-Identifier: GPL-3.0-or-later
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pylintreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

import pytest
import pandas as pd
import html

import pandas as pd

from codeaudit.reporting import pylint_reporting


Expand Down
4 changes: 2 additions & 2 deletions tests/test_pypiscan.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from unittest.mock import patch

import pytest

from codeaudit.pypi_package_scan import get_pypi_download_info

# Note This testfunction does NOT make real API calls to PyPI! So check if testdata is still correct in cause of errors.

from unittest.mock import patch


@pytest.fixture
def mock_pypi_response():
Expand Down
3 changes: 0 additions & 3 deletions tests/test_random.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.issuevalidations import find_constructs
from codeaudit.security_checks import perform_validations


Expand Down
3 changes: 1 addition & 2 deletions tests/test_secretfinding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from pathlib import Path

from codeaudit.privacy_lint import data_egress_scan, count_privacy_check_results
from codeaudit.privacy_lint import count_privacy_check_results, data_egress_scan


def test_secretfinding():
Expand Down
1 change: 0 additions & 1 deletion tests/test_standardlibconstructs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
Expand Down
1 change: 0 additions & 1 deletion tests/test_subprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.security_checks import perform_validations
Expand Down
1 change: 0 additions & 1 deletion tests/test_suppression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from pathlib import Path

from codeaudit.security_checks import perform_validations
Expand Down
4 changes: 3 additions & 1 deletion tests/test_suppressionlogic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import textwrap

import pytest

from codeaudit.suppression import get_all_comments_by_line , match_suppression_keyword
from codeaudit.suppression import get_all_comments_by_line, match_suppression_keyword


def test_get_all_comments_by_line(tmp_path):
source = textwrap.dedent(
Expand Down
4 changes: 1 addition & 3 deletions tests/test_totalscheck.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file

from codeaudit.totals import read_in_source_file, overview_per_file, count_ast_objects
from codeaudit.totals import count_ast_objects, overview_per_file, read_in_source_file


def test_overview_per_file_check():
Expand Down
3 changes: 0 additions & 3 deletions tests/test_zstd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pytest
from pathlib import Path

from codeaudit.filehelpfunctions import read_in_source_file
from codeaudit.issuevalidations import find_constructs
from codeaudit.security_checks import perform_validations


Expand Down
Loading