db

package
v0.0.0-...-14fdc2a Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHosts

func AddHosts(app *util.App, hosts []string) error

AddHosts is a function that allows you to add hosts to the Xray DB. The argument app must contain a DB ID.

func AddPackages

func AddPackages(app *util.App) error

AddPackages is a function that allows you to add packages to the Xray DB. The argument app must contain a DB ID and an array of package names.

func AddPerms

func AddPerms(app *util.App) error

AddPerms is a function that allows you to add permissions to the Xray DB. The argument app must contain a DB ID and an array of permissions.

func GetAppHostIDs

func GetAppHostIDs() ([]int64, error)

GetAppHostIDs returns an array of app_version ids found in app_hosts.

func GetManualAltApps

func GetManualAltApps(appID string) ([]string, error)

GetManualAltApps - Returns app ids that are logged as alternatives to the one given.

func HasAppVersionID

func HasAppVersionID(appID int64) bool

HasAppVersionID Checks if app_versions table has the provided appversionId

func HasCompanyAppAssociation

func HasCompanyAppAssociation(appID int64, companyName string) bool

HasCompanyAppAssociation checks if an association between a given app and company name already exists.

func HasCompanyName

func HasCompanyName(companyName string) bool

HasCompanyName Checks if companyNames table has the provided company name

func IncrementCompanyAppAssociationCount

func IncrementCompanyAppAssociationCount(appID int64, companyName string) error

IncrementCompanyAppAssociationCount increments the counter on the associated app and company

func InsertCompanyAppAssociation

func InsertCompanyAppAssociation(appID int64, companyName string) error

InsertCompanyAppAssociation inserts an app and company name association into the database.

func InsertCompanyName

func InsertCompanyName(companyName string) error

InsertCompanyName inserts the provided company name into the database.

func Open

func Open(cfg util.Config, enable bool) error

Open opens the database with the given config. If enable is false, the functions that modify the database are noops.

func SelectCompanyNames

func SelectCompanyNames() ([]string, error)

SelectCompanyNames returns an array of company names found in the DB.

func SetAnalyzed

func SetAnalyzed(id int64) error

SetAnalyzed sets analyzed=True for a given app.

func SetIcon

func SetIcon(id int64, icon string) error

SetIcon is a function that sets the icon field of the DB.

func SetLastAnalyzeAttempt

func SetLastAnalyzeAttempt(id int64) error

SetLastAnalyzeAttempt sets the last_analyzed_attempt of an app to the current time.

func SetManifest

func SetManifest(id int64, manifest string) error

SetManifest is a function that sets the manifest field of the DB.

func SetReflect

func SetReflect(id int64, val bool) error

SetReflect sets the value of uses_reflect for an app version

func UnsetDownloaded

func UnsetDownloaded(id int64) error

UnsetDownloaded sets an downloaded=False for given app.

Types

type APIRequestError

type APIRequestError struct {
	ErrorType    string `json:"ErrorType"`
	ErrorMessage string `json:"ErrorMsg"`
	APIRequest   string `json:"APIRequest"`
}

APIRequestError holds Error information sent via the API should na endpoint fail.

type AltApp

type AltApp struct {
	AltAppTitle     string `json:"altAppTitle"`
	AltToURL        string `json:"altToURL"`
	GPlayURL        string `json:"gPlayURL"`
	GPlayID         string `json:"gPlayID"`
	IconURL         string `json:"iconURL"`
	OfficialSiteURL string `json:"officialSiteURL"`
	IsScraped       bool   `json:"isScraped"`
}

AltApp represents Alternative App title and playstore url. Used in API

func GetAltApps

func GetAltApps(appID string) ([]AltApp, error)

GetAltApps takes an app's DB ID and returns a collection of alternative apps for the specified app - For the API

type App

type App struct {
	ID   string  `json:"id"`
	Vers []int64 `json:"vers"`
}

App represents an app from the database

func GetApp

func GetApp(id string) (App, error)

GetApp gets an app given its id, in the form com.example.app.

func GetApps

func GetApps(num, start int) ([]App, error)

GetApps returns a list of apps.

func GetLatestApps

func GetLatestApps(num, start int) ([]App, error)

GetLatestApps returns a list of the newest app versions.

TODO: THIS IS WRONG.

type AppAssociations

type AppAssociations struct {
	AppVersionID        int64               `json:"appVersionID"`
	AssociatedCompanies []AssociatedCompany `json:"associatedCompanies"`
}

AppAssociations holds the result of a query to the DB for all company names with an app association.

func GetAppVersionAssociations

func GetAppVersionAssociations(appID int64) (AppAssociations, error)

GetAppVersionAssociations returns an AppAssociations object containing an array of Company names and the number of times they are associated with this company.

type AppHostRecord

type AppHostRecord struct {
	ID        int64    `json:"id"`
	HostNames []string `json:"hostnames"`
}

AppHostRecord holds app_host data from the xray DB

func GetAppHostsByID

func GetAppHostsByID(id int64) (AppHostRecord, error)

GetAppHostsByID selects an app host record from the DB using the provided ID

type AppStub

type AppStub struct {
	Title string `json:"title"`
	App   string `json:"app"`
}

AppStub represents the 'stub' of app data located in the Database. it is formed of only the title given to the app by the developer and the App ID that it can be uniquely identified as.

type AppVersion

type AppVersion struct {
	ID              int64     `json:"id"`
	App             string    `json:"app"`
	Store           string    `json:"string"`
	Region          string    `json:"region"`
	Ver             string    `json:"ver"`
	ScreenFlags     int64     `json:"screenFlags"`
	StoreInfo       StoreInfo `json:"storeinfo"`
	Icon            string    `json:"icon"`
	Dev             Developer `json:"developer"`
	Hosts           []string  `json:"hosts"`
	Perms           []string  `json:"perms"`
	Packages        []string  `json:"packages"`
	IsAnalyzed      bool      `json:"isAnalyzed"`
	APKLocationUUID string    `json:"apkLocationUUID"`
	APKLocationPath string    `json:"apkLocationPath"`
	APKLocationRoot string    `json:"apkLocationRoot"`
}

AppVersion represents all the information about an app version contained in the database

func GetAppVersion

func GetAppVersion(app, store, region, version string) (AppVersion, error)

GetAppVersion gets an app version from the database. The argument app is the app id, in the form com.example.app.

func GetAppVersionByID

func GetAppVersionByID(id int64) (AppVersion, error)

GetAppVersionByID gets an app version given its ID in the database.

func GetAppsToAnalyze

func GetAppsToAnalyze(limit int64) ([]AppVersion, error)

GetAppsToAnalyze returns a list of up to `limit` apps that have analyzed=False and downloaded=True for the analyzer.

func QueryAll

func QueryAll(
	onlyAnalyzed bool, appStore string, limit string, offset string, developers []string,
	genres []string, permissions []string, appIDs []string, titles []string, startsWith []string,
) ([]AppVersion, error)

QueryAll depricates all of dean's queries.

func (AppVersion) UtilApp

func (a AppVersion) UtilApp() *util.App

UtilApp creates a *util.App from an AppVersion

type AssociatedCompany

type AssociatedCompany struct {
	CompanyName          string `json:"companyName"`
	NumberOfAssociations int64  `json:"numberOfAssociations"`
}

AssociatedCompany holds the name of a company and the number of associations that it has.

type Company

type Company struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Hosts        []string `json:"nosts"`
	Founded      string   `json:"founded"`
	Acquired     string   `json:"acquired"`
	Type         []string `json:"type"`
	TypeTag      string   `json:"typeTag"`
	Jurisdiction string   `json:"jurisdiction"`
	Parent       string   `json:"parent"`
	Capital      string   `json:"capital"`
	Equity       string   `json:"equity"`
	Size         Range    `json:"size"`
	DataSources  []string `json:"dataSources"`
	Description  []string `json:"description"`
}

Company represents a company from the database

func GetCompanies

func GetCompanies(num, start int) ([]Company, error)

GetCompanies returns a list of companies.

func GetCompany

func GetCompany(id string) (Company, error)

GetCompany returns a company given its ID in the database.

type CompanyAssociations

type CompanyAssociations struct {
	CompanyName            string  `json:"companyName"`
	AssociatedAppIDs       []int64 `json:"associatedAppIDs"`
	AssociatedIoTDeviceIDs []int64 `json:"associatedIoTDeviceIDs"`
	AssociatedWebsiteIDs   []int64 `json:"associatedWebsiteIDs"`
}

CompanyAssociations holds a record of from the DB describing the associations between a single company and various apps/devices/websites.

func GetCompanyAssocations

func GetCompanyAssocations(companyName string) (CompanyAssociations, error)

GetCompanyAssocations fetches the associations logged between a company and apps/websits/devices.

type CompanyCoverage

type CompanyCoverage struct {
	Company     string  `json:"company"`
	Type        string  `json:"type"`
	AppCount    int64   `json:"appCount"`
	TotalApps   int64   `json:"totalApps"`
	CompanyFreq float64 `json:"companyFreq"`
}

CompanyCoverage represents a row from the company_app_coverage statistics table found in the XRay DB.

func GetAppCompanyFreq

func GetAppCompanyFreq() ([]CompanyCoverage, error)

GetAppCompanyFreq Queries the DB for global company stats. a generalised get Stat Freq table method should be created where the name of a freq table is specified. the tables would take a standardised format.

type CompanyGenreCoverage

type CompanyGenreCoverage struct {
	Company      string  `json:"company"`
	CompanyCount int64   `json:"companyCount"`
	Genre        string  `json:"genre"`
	GenreTotal   int64   `json:"genreTotal"`
	CoveragePct  float64 `json:"companyPct"`
}

CompanyGenreCoverage Stats for company Genre Coverage.

func GetCompanyGenreCoverage

func GetCompanyGenreCoverage() ([]CompanyGenreCoverage, error)

GetCompanyGenreCoverage queries DB for stats.

type CompanyNames

type CompanyNames struct {
	CompanyNames []string `json:"companyNames"`
}

CompanyNames represents the json structure used to send company names selected from the DB via the rest API.

type CompanyTypeCoverage

type CompanyTypeCoverage struct {
	Type      string  `json:"type"`
	AppCount  int64   `json:"appCount"`
	TotalApps int64   `json:"totalApps"`
	TypeFreq  float64 `json:"typeFreq"`
}

CompanyTypeCoverage represents a row from the app_type_coverage statistics table found in the XRay DB

func GetAppTypeFreq

func GetAppTypeFreq() ([]CompanyTypeCoverage, error)

GetAppTypeFreq Querys the DB for rows in the app_types_coverage stats table

type Developer

type Developer struct {
	Emails    []string `json:"emails"`
	Name      string   `json:"name"`
	StoreSite string   `json:"storeSite"`
	Site      string   `json:"site"`
}

Developer represents a developer from the database

func GetDeveloper

func GetDeveloper(id int64) (Developer, error)

GetDeveloper gets a developer given its ID in the database.

func GetDevelopers

func GetDevelopers(num, start int) ([]Developer, error)

GetDevelopers returns a list of developers.

type GenreStats

type GenreStats struct {
	Category  string  `json:"category"`
	HostCount int64   `json:"hostCount"`
	AppCount  int64   `json:"appCount"`
	GenreAvg  float64 `json:"genreAvg"`
}

GenreStats represents a row from the Genre average statistics table

func GetGenreHostAverages

func GetGenreHostAverages() ([]GenreStats, error)

GetGenreHostAverages Queries DB for Genre averages stats view.

type PlayStoreInfo

type PlayStoreInfo struct {
	Title         string    `json:"title"`
	Summary       string    `json:"summary"` //TODO:Omitempty for null vlaues?
	Description   string    `json:"description"`
	StoreURL      string    `json:"storeURL"`
	Price         string    `json:"price"`
	Free          bool      `json:"free"`
	Rating        string    `json:"rating"`
	NumReviews    int64     `json:"numReviews"`
	Genre         string    `json:"genre"`
	FamilyGenre   string    `json:"familyGenre"`
	Installs      Range     `json:"installs"`
	Developer     int64     `json:"developer"`
	Updated       time.Time `json:"updated"`
	AndroidVer    string    `json:"androidVer"`
	ContentRating string    `json:"contentRating"`
	Screenshots   []string  `json:"screenshots"`
	Video         string    `json:"video"`
	RecentChanges []string  `json:"recentChanges"`
	CrawlDate     time.Time `json:"crawlDate"`
	Permissions   []string  `json:"permissions"`
}

PlayStoreInfo represents the data contained in the google play store

type Range

type Range struct {
	Min int64 `json:"min"`
	Max int64 `json:"max"`
}

Range represents a range

type StoreInfo

type StoreInfo interface{}

StoreInfo represents the information contained about an app in its respective store

type TrackerMapperCompany

type TrackerMapperCompany struct {
	HostName    string   `json:"hostName"`
	HostID      int64    `json:"hostID"`
	CompanyName string   `json:"companyName"`
	CompanyID   int64    `json:"companyID"`
	Locale      string   `json:"locale"`
	Categories  []string `json:"categories"`
}

TrackerMapperCompany holds the data requested from the OxfordHCC TrackerMapper API.

type TrackerMapperRequest

type TrackerMapperRequest struct {
	HostNames []string `json:"host_names"`
}

TrackerMapperRequest holds the data used in requests to the OxfordHCC TrackerMapper API.

Jump to

Keyboard shortcuts

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