browserutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package browserutils provides utility functions for handling browser-related operations. These functions are used in the context of performing security checks on a system.

Exported function(s): CloseFile, FirefoxFolder, GetPhishingDomains, CopyFile

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFile

func CloseFile(file mocking.File) error

CloseFile is a utility function that closes a given file and logs any errors that occur during the process.

Parameters:

  • file *filemock.File: The file that needs to be closed. It is an instance of a File from the filemock package.

Returns:

  • error: An error object that wraps any error that occurs during file closure. If the file is closed successfully, it returns nil.

func CopyFile

func CopyFile(src, dst string, mockSource mocking.File, mockDestination mocking.File) error

CopyFile is a utility function that copies a file from a source path to a destination path.

Parameters:

  • src string: The path to the source file that needs to be copied.
  • dst string: The path to the destination where the source file should be copied to.

dst - the destination file

Returns:

  • error: An error object that wraps any error that occurs during the file copying process. If the file is copied successfully, it returns nil.

func GetPhishingDomains

func GetPhishingDomains() []string

GetPhishingDomains retrieves a list of active phishing domains from a remote database.

This function sends a GET request to the URL of the phishing database hosted on GitHub. It reads the response body, which contains a list of active phishing domains, each on a new line. The function then splits this response into a slice of strings, where each string represents a single phishing domain.

Returns:

  • []string: A slice containing the phishing domains. If an error occurs during the retrieval or parsing of the domains, an empty slice is returned.

Types

type FirefoxProfileFinder

type FirefoxProfileFinder interface {
	FirefoxFolder() ([]string, error)
}

FirefoxProfileFinder is an interface that wraps the FirefoxFolder method

type MockProfileFinder

type MockProfileFinder struct {
	MockFirefoxFolder func() ([]string, error)
}

MockProfileFinder is a struct that implements the FirefoxProfileFinder interface for testing

func (MockProfileFinder) FirefoxFolder

func (m MockProfileFinder) FirefoxFolder() ([]string, error)

FirefoxFolder is a mock function

type RealProfileFinder

type RealProfileFinder struct{}

RealProfileFinder is a struct that implements the FirefoxProfileFinder interface

func (RealProfileFinder) FirefoxFolder

func (r RealProfileFinder) FirefoxFolder() ([]string, error)

FirefoxFolder retrieves the paths to all Firefox profile folders for the currently logged-in user.

This function uses the os/user package to access the current user's information and constructs the path to the Firefox profile directory. It then reads the directory and filters out all non-directory files. For each directory, it checks if a 'logins.json' file exists. If such a file exists, the directory is considered a Firefox profile folder and its path is added to the returned list.

Returns:

  • []string: A slice containing the paths to all Firefox profile folders. If no profile folders are found or an error occurs, an empty slice is returned.
  • error: An error object that wraps any error that occurs during the retrieval of the Firefox profile folders. If the folders are retrieved successfully, it returns nil.

Jump to

Keyboard shortcuts

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