scan

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

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

func FillDataBase(scanResults []checks.Check)

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:

  1. Opens a connection to the SQLite database located at "./database.db". If the database does not exist, it is created.
  2. Drops the existing "issues" table if it exists.
  3. Creates a new "issues" table with columns for JSON Key, Issue ID, Result ID, and Severity.
  4. Clears any existing rows in the "issues" table.
  5. Iterates over the scanResults slice and adds each Check object to the "issues" table as a new row.
  6. 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

func GetJSONKey(db *sql.DB, issueID int, resultID int) (int, error)

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

func GetSeverity(db *sql.DB, issueID int, resultID int) (int, error)

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:

  1. Prepares an SQL SELECT statement to retrieve the severity level of the issue from the 'issues' table.
  2. Executes the SQL statement, passing in the issueID and resultID as parameters.
  3. 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.
  4. 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:

  1. Defines all security/privacy checks that should be executed.
  2. Iterates over each check, displaying the currently running check in the progress dialog and executing the check.
  3. Appends the result of each check to the checkResults slice.
  4. 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL