sricheck

package module
v0.0.0-...-477aff2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

README

sricheck

A GoLang subresource integrity check module

Exported Functions

GenerateSriMap

Used to make integrity attributes from a given resource.

Inputs
  • jsSrc string - a string URL to a file, generally JS or CSS
Returns
  • a map of hashes for that data (map[string]string). The index, or key, of the map will be a string of the hash algorithm. The value of the map will be the base64 hash for the data
  • error

CheckPageIntegrity

Used to check all of the intrgrity attributes on a page.

Inputs
  • pageUrl - a string URL to a page
Returns
  • Return a boolean value based on the integrity checks - true when all integrity attributes are valid (or not present) and false when an integrity attribute does not check correctly.
  • error

PrintPageIntegrityCheckTable

Used to print out (to cli) a nice table for enumerating JS resources, integrity attributes, and their validity.

Inputs
  • pageUrl - a string URL to a page
Output

Print a table summarizing all of the JS includes, their integrity attributes, and the validity of integrity attributes

Returns

None

CheckIntegrity

Used to check a provided integrity attribute for a provided URL.

Inputs
  • jsSrc - a string URL to a file (generally a JS or CSS file)
  • integrity - the string of the integrity attribute
Returns
  • a boolean - Returns true for valid and false for invalid
  • error

Other Todos:

[ ] Improve testing

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIntegrity

func CheckIntegrity(jsSrc string, integrity string) (bool, error)

Given a string URL to a file (generally a JS or CSS file) and the string of the integrity attribute, determine if the integrity attribute is valid Returns true for valid and false for invalid

func CheckPageIntegrity

func CheckPageIntegrity(pageUrl string) (bool, error)

Given a string URL to a page, request that page (via HTTP GET) and note the script blocks with SRC attributes Check the Integrity attribute for any noted JS includes Return a boolean value based on the integrity checks - true when all integrity attributes are valid (or not present) and false when an integrity attribute does not check correctly.

func GenerateSriMap

func GenerateSriMap(jsSrc string) (map[string]string, error)

Given a string URL to a file (generally a JS or CSS file), generate a map of hashes for that data The index, or key, of the map will be a string of the hash algorithm The value of the map will be the base64 hash for the data

func PrintPageIntegrityCheckTable

func PrintPageIntegrityCheckTable(pageUrl string)

Given a string URL to a page, request that page (via HTTP GET) and note the script blocks with SRC attributes Check the Integrity attribute for any noted JS includes Print a table summarizing all of the JS includes, their integrity attributes, and the validity of integrity attributes

Types

type PageScript

type PageScript struct {
	Url                string
	IntegrityAttribute string
}

Jump to

Keyboard shortcuts

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