Documentation ¶
Overview ¶
Package scan collects all different privacy/security checks and provides a function that runs them all.
Exported function(s): Scan
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillDataBase ¶
FillDataBase clears the existing issues table and populates it with the results from a scan.
Parameters:
- scanResults ([]checks.Check): A slice of Check objects obtained from a scan. Each Check object represents a security check that has been performed.
This function performs the following operations:
- Opens a connection to the SQLite database located at "./database.db". If the database does not exist, it is created.
- Drops the existing "issues" table if it exists.
- Creates a new "issues" table with columns for JSON Key, Issue ID, Result ID, and Severity.
- Clears any existing rows in the "issues" table.
- Iterates over the scanResults slice and adds each Check object to the "issues" table as a new row.
- Closes the connection to the database.
Note: This function logs any errors that occur during its execution and does not return any values.
func GetJSONKey ¶
GetJSONKey gets the single JSON key of an issue
Parameters:
db (*sql.DB) - database connection where table resides
issueId (int) - id of the issue
resultId (int) - id of the result of the issue
Returns: JSON key of the issue
func GetSeverity ¶
GetSeverity retrieves the severity level of a specific issue from the 'issues' table in the database.
Parameters:
- db (*sql.DB): The database connection where the 'issues' table resides.
- issueID (int): The unique identifier of the issue. This is used as a reference in the 'issues' table.
- resultID (int): The unique identifier of the result of the issue. This is used as a reference in the 'issues' table.
This function performs the following operations:
- Prepares an SQL SELECT statement to retrieve the severity level of the issue from the 'issues' table.
- Executes the SQL statement, passing in the issueID and resultID as parameters.
- If an error occurs while executing the SQL statement, it logs the error and returns it along with a zero value for the severity level.
- If the SQL statement executes successfully, it retrieves the severity level from the result and returns it along with a nil error.
Returns:
- int: The severity level of the issue. This is represented as an integer where a higher value indicates a higher severity.
- error: An error object that describes the error (if any) that occurred while retrieving the severity level. If no error occurred, this value is nil.
func Scan ¶
func Scan(dialog zenity.ProgressDialog) ([]checks.Check, error)
Scan executes all security/privacy checks, serializes the results to JSON, and returns a list of all found issues.
Parameters:
- dialog (zenity.ProgressDialog): A dialog window that displays the progress of the scan as it runs.
This function performs the following operations:
- Iterates over each check, displaying the currently running check in the progress dialog and executing the check.
- Appends the result of each check to the checkResults slice.
- Serializes the checkResults slice to JSON and logs the JSON data.
Returns:
- []checks.Check: A slice of Check objects representing all found issues.
- error: An error object that describes the error (if any) that occurred while running the checks or serializing the results to JSON. If no error occurred, this value is nil.
Types ¶
type DataBaseData ¶
type DataBaseData struct { CheckID int `json:"id"` Severity int `json:"severity"` JSONKey int `json:"jsonkey"` }
DataBaseData is a struct which is used to format extracted information from the database
CheckId is used as the identifier to connect the severity level and JSON key to
func GetDataBaseData ¶
func GetDataBaseData(checks []checks.Check) ([]DataBaseData, error)
GetDataBaseData gets the severities and JSON keys for all checks passed
Parameters: checks ([]checks.Check) - the list of checks from a scan
resultIDs ([]int) - the list of results corresponding to each check
Returns: list of all severities and JSON keys