Coverage for src / codeaudit / api_reporting.py: 0%
12 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-09 09:33 +0200
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-09 09:33 +0200
1"""
2License GPLv3 or higher.
4(C) 2025 Created by Maikel Mardjan - https://nocomplexity.com/
6This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
13Public API functions for Python Code Audit aka codeaudit on pypi.org
15All reporting API functions are created based on the Code Audit JSON format that is used when scan results are stored using the `codeaudit.api_interfaces.save_to_json` call!
17These API functions are on purpose opinionated for one goal: Keep things simple!
18So all results are returned as Pandas Dataframe. This makes things easier for further processing!
20"""
22from collections import Counter
24import pandas as pd
27def total_weaknesses(input_file):
28 """Returns the total weaknesses found"""
29 scan_result = input_file
30 counter = Counter()
32 for file_info in scan_result.get("file_security_info", {}).values():
33 sast_result = file_info.get("sast_result", {})
34 for (
35 construct,
36 occurence,
37 ) in (
38 sast_result.items()
39 ): # occurence is times the construct appears in a single file
40 counter[construct] += len(occurence)
42 result = dict(counter)
43 df = pd.DataFrame(list(result.items()), columns=["call", "count"])
44 return df