Documentation ¶
Overview ¶
Package services handles the logic behind all of the Web/API actions
Index ¶
- Variables
- func AddEvidenceToFinding(ctx context.Context, db *database.Connection, i AddEvidenceToFindingInput) error
- func AddUsersToGroup(tx *database.Transactable, userSlugs []string, groupID int64) error
- func BatchRunServiceWorker(ctx context.Context, db *database.Connection, i BatchRunServiceWorkerInput) error
- func CreateAPIKey(ctx context.Context, db *database.Connection, userSlug string) (*dtos.APIKey, error)
- func CreateDefaultTag(ctx context.Context, db *database.Connection, i CreateDefaultTagInput) (*dtos.DefaultTag, error)
- func CreateEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) (*dtos.Evidence, error)
- func CreateEvidenceMetadata(ctx context.Context, db *database.Connection, i EditEvidenceMetadataInput) error
- func CreateFinding(ctx context.Context, db *database.Connection, i CreateFindingInput) (*dtos.Finding, error)
- func CreateFindingCategory(ctx context.Context, db *database.Connection, newCategory string) (*dtos.FindingCategory, error)
- func CreateGlobalVar(ctx context.Context, db *database.Connection, i CreateGlobalVarInput) (*dtos.GlobalVar, error)
- func CreateHeadlessUser(ctx context.Context, db *database.Connection, i CreateUserInput) (*dtos.CreateUserOutput, error)
- func CreateOperation(ctx context.Context, db *database.Connection, i CreateOperationInput) (*dtos.Operation, error)
- func CreateOperationVar(ctx context.Context, db *database.Connection, i CreateOperationVarInput) (*dtos.OperationVar, error)
- func CreateQuery(ctx context.Context, db *database.Connection, i CreateQueryInput) (*dtos.Query, error)
- func CreateServiceWorker(ctx context.Context, db *database.Connection, i CreateServiceWorkerInput) error
- func CreateTag(ctx context.Context, db *database.Connection, i CreateTagInput) (*dtos.Tag, error)
- func CreateUser(db *database.Connection, i CreateUserInput) (*dtos.CreateUserOutput, error)
- func CreateUserGroup(ctx context.Context, db *database.Connection, i CreateUserGroupInput) (*dtos.UserGroup, error)
- func DeleteAPIKey(ctx context.Context, db *database.Connection, i DeleteAPIKeyInput) error
- func DeleteAuthScheme(ctx context.Context, db *database.Connection, i DeleteAuthSchemeInput) error
- func DeleteAuthSchemeUsers(ctx context.Context, db *database.Connection, schemeCode string) error
- func DeleteDefaultTag(ctx context.Context, db *database.Connection, i DeleteDefaultTagInput) error
- func DeleteEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) error
- func DeleteFinding(ctx context.Context, db *database.Connection, i DeleteFindingInput) error
- func DeleteFindingCategory(ctx context.Context, db *database.Connection, i DeleteFindingCategoryInput) error
- func DeleteGlobalVar(ctx context.Context, db *database.Connection, name string) error
- func DeleteOperation(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) error
- func DeleteOperationVar(ctx context.Context, db *database.Connection, varSlug string, ...) error
- func DeleteQuery(ctx context.Context, db *database.Connection, i DeleteQueryInput) error
- func DeleteServiceWorker(ctx context.Context, db *database.Connection, i DeleteServiceWorkerInput) error
- func DeleteSessionsForUserSlug(ctx context.Context, db *database.Connection, userSlug string) error
- func DeleteTag(ctx context.Context, db *database.Connection, i DeleteTagInput) error
- func DeleteUser(ctx context.Context, db *database.Connection, slug string) error
- func DeleteUserGroup(ctx context.Context, db *database.Connection, slug string) error
- func ListAPIKeys(ctx context.Context, db *database.Connection, userSlug string) ([]*dtos.APIKey, error)
- func ListActiveServices(ctx context.Context, db *database.Connection) ([]*dtos.ActiveServiceWorker, error)
- func ListAuthDetails(ctx context.Context, db *database.Connection, ...) ([]*dtos.DetailedAuthenticationInfo, error)
- func ListDefaultTags(ctx context.Context, db *database.Connection) ([]*dtos.DefaultTag, error)
- func ListEvidenceCreatorsForOperation(ctx context.Context, db *database.Connection, ...) ([]*dtos.User, error)
- func ListEvidenceForFinding(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) ([]dtos.Evidence, error)
- func ListEvidenceForOperation(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) ([]*dtos.Evidence, error)
- func ListFindingCategories(ctx context.Context, db *database.Connection, includeDeleted bool) (interface{}, error)
- func ListFindingsForOperation(ctx context.Context, db *database.Connection, i ListFindingsForOperationInput) ([]*dtos.Finding, error)
- func ListGlobalVars(ctx context.Context, db *database.Connection) ([]*dtos.GlobalVar, error)
- func ListOperationVars(ctx context.Context, db *database.Connection, operationSlug string) ([]*dtos.OperationVar, error)
- func ListOperations(ctx context.Context, db *database.Connection) ([]*dtos.Operation, error)
- func ListOperationsForAdmin(ctx context.Context, db *database.Connection) ([]*dtos.Operation, error)
- func ListQueriesForOperation(ctx context.Context, db *database.Connection, operationSlug string) ([]*dtos.Query, error)
- func ListServiceWorker(ctx context.Context, db *database.Connection) ([]*dtos.ServiceWorker, error)
- func ListTagDifference(ctx context.Context, db *database.Connection, i ListTagsDifferenceInput) (*dtos.TagDifference, error)
- func ListTagDifferenceForEvidence(ctx context.Context, db *database.Connection, ...) (*dtos.TagDifference, error)
- func ListTagsForOperation(ctx context.Context, db *database.Connection, i ListTagsForOperationInput) ([]*dtos.TagWithUsage, error)
- func ListUserGroups(ctx context.Context, db *database.Connection, i ListUserGroupsInput) ([]*dtos.UserGroupAdminView, error)
- func ListUserGroupsForAdmin(ctx context.Context, db *database.Connection, i ListUserGroupsForAdminInput) ([]dtos.UserGroupAdminView, error)
- func ListUserGroupsForOperation(ctx context.Context, db *database.Connection, ...) ([]*dtos.UserGroupOperationRole, error)
- func ListUsers(ctx context.Context, db *database.Connection, i ListUsersInput) ([]*dtos.User, error)
- func ListUsersForAdmin(ctx context.Context, db *database.Connection, i ListUsersForAdminInput) (*dtos.PaginationWrapper, error)
- func ListUsersForOperation(ctx context.Context, db *database.Connection, i ListUsersForOperationInput) ([]*dtos.UserOperationRole, error)
- func LookupGlobalVar(db *database.Connection, name string) (*models.GlobalVar, error)
- func LookupOperationVar(db *database.Connection, varSlug string) (*models.OperationVar, error)
- func MergeDefaultTags(ctx context.Context, db *database.Connection, i []CreateDefaultTagInput) error
- func ModifyUserGroup(ctx context.Context, db *database.Connection, i ModifyUserGroupInput) (*dtos.UserGroup, error)
- func MoveEvidence(ctx context.Context, db *database.Connection, i MoveEvidenceInput) error
- func ReadEvidenceMetadata(ctx context.Context, db *database.Connection, i ReadEvidenceMetadataInput) ([]*dtos.EvidenceMetadata, error)
- func ReadFinding(ctx context.Context, db *database.Connection, i ReadFindingInput) (*dtos.Finding, error)
- func ReadOperation(ctx context.Context, db *database.Connection, operationSlug string) (*dtos.Operation, error)
- func ReadUser(ctx context.Context, db *database.Connection, userSlug string, ...) (*dtos.UserOwnView, error)
- func RunServiceWorker(ctx context.Context, db *database.Connection, i RunServiceWorkerInput) error
- func SanitizeSlug(slug string) string
- func SelfOrSlugToUserID(ctx context.Context, db *database.Connection, slug string) (int64, error)
- func SendURLData(ctx context.Context, db *database.Connection, ...) (*contentstore.URLData, error)
- func SetFavoriteOperation(ctx context.Context, db *database.Connection, i SetFavoriteInput) error
- func SetUserFlags(ctx context.Context, db *database.Connection, i SetUserFlagsInput) error
- func SetUserGroupOperationRole(ctx context.Context, db *database.Connection, i SetUserGroupOperationRoleInput) error
- func SetUserOperationRole(ctx context.Context, db *database.Connection, i SetUserOperationRoleInput) error
- func SortUsersInToGroups(slugMap SlugMap) ([]dtos.UserGroupAdminView, error)
- func TestServiceWorker(ctx context.Context, db *database.Connection, serviceWorkerID int64) (*dtos.ServiceWorkerTestOutput, error)
- func UpdateDefaultTag(ctx context.Context, db *database.Connection, i UpdateDefaultTagInput) error
- func UpdateEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, ...) error
- func UpdateEvidenceMetadata(ctx context.Context, db *database.Connection, i EditEvidenceMetadataInput) error
- func UpdateFinding(ctx context.Context, db *database.Connection, i UpdateFindingInput) error
- func UpdateFindingCategory(ctx context.Context, db *database.Connection, i UpdateFindingCategoryInput) error
- func UpdateGlobalVar(ctx context.Context, db *database.Connection, i UpdateGlobalVarInput) error
- func UpdateOperation(ctx context.Context, db *database.Connection, i UpdateOperationInput) error
- func UpdateOperationVar(ctx context.Context, db *database.Connection, i UpdateOperationVarInput) error
- func UpdateQuery(ctx context.Context, db *database.Connection, i UpdateQueryInput) error
- func UpdateServiceWorker(ctx context.Context, db *database.Connection, i UpdateServiceWorkerInput) error
- func UpdateTag(ctx context.Context, db *database.Connection, i UpdateTagInput) error
- func UpdateUserProfile(ctx context.Context, db *database.Connection, i UpdateUserProfileInput) error
- func UpsertEvidenceMetadata(ctx context.Context, db *database.Connection, i UpsertEvidenceMetadataInput) error
- func UpsertQuery(ctx context.Context, db *database.Connection, i UpsertQueryInput) (*dtos.Query, error)
- type AddEvidenceToFindingInput
- type BatchRunServiceWorkerInput
- type CreateDefaultTagInput
- type CreateEvidenceInput
- type CreateFindingInput
- type CreateGlobalVarInput
- type CreateOperationInput
- type CreateOperationVarInput
- type CreateQueryInput
- type CreateServiceWorkerInput
- type CreateTagInput
- type CreateUserGroupInput
- type CreateUserInput
- type DeleteAPIKeyInput
- type DeleteAuthSchemeInput
- type DeleteDefaultTagInput
- type DeleteEvidenceInput
- type DeleteFindingCategoryInput
- type DeleteFindingInput
- type DeleteGlobalVarInput
- type DeleteOperationVarInput
- type DeleteQueryInput
- type DeleteServiceWorkerInput
- type DeleteTagInput
- type EditEvidenceMetadataInput
- type EvidenceCountWithID
- type ExpandedTagUsageData
- type ListEvidenceCreatorsForOperationInput
- type ListEvidenceForFindingInput
- type ListEvidenceForOperationInput
- type ListFindingsForOperationInput
- type ListTagDifferenceForEvidenceInput
- type ListTagsDifferenceInput
- type ListTagsForOperationInput
- type ListUserGroupsForAdminInput
- type ListUserGroupsForOperationInput
- type ListUserGroupsInput
- type ListUsersForAdminInput
- type ListUsersForOperationInput
- type ListUsersInput
- type ModifyUserGroupInput
- type MoveEvidenceInput
- type OperationWithID
- type Pagination
- type ReadEvidenceInput
- type ReadEvidenceMetadataInput
- type ReadEvidenceOutput
- type ReadFindingInput
- type RunServiceWorkerInput
- type SetFavoriteInput
- type SetUserFlagsInput
- type SetUserGroupOperationRoleInput
- type SetUserOperationRoleInput
- type SlugMap
- type TagUsageItem
- type TopContribWithID
- type UpdateDefaultTagInput
- type UpdateEvidenceInput
- type UpdateFindingCategoryInput
- type UpdateFindingInput
- type UpdateGlobalVarInput
- type UpdateOperationInput
- type UpdateOperationVarInput
- type UpdateQueryInput
- type UpdateServiceWorkerInput
- type UpdateTagInput
- type UpdateUserProfileInput
- type UpsertEvidenceMetadataInput
- type UpsertQueryInput
- type UserFilter
- type UserGroupFilter
Constants ¶
This section is empty.
Variables ¶
var EvidenceCountForAllOperations string = fmt.Sprintf(`
%s
GROUP BY
operation_id`, getCountsFromEvidence)
var GetTopContributorsForEachOperation string = fmt.Sprintf(`
SELECT
t1.*
FROM (%s
GROUP BY
operation_id,
users.id) t1
LEFT JOIN (
%s
GROUP BY
operation_id,
users.id) t2 ON t1.operation_id = t2.operation_id
AND t1.count < t2.count
WHERE
t2.count IS NULL`, getDataFromEvidence, getDataFromEvidence)
Functions ¶
func AddEvidenceToFinding ¶
func AddEvidenceToFinding(ctx context.Context, db *database.Connection, i AddEvidenceToFindingInput) error
func AddUsersToGroup ¶
func AddUsersToGroup(tx *database.Transactable, userSlugs []string, groupID int64) error
func BatchRunServiceWorker ¶
func BatchRunServiceWorker(ctx context.Context, db *database.Connection, i BatchRunServiceWorkerInput) error
func CreateAPIKey ¶
func CreateDefaultTag ¶
func CreateDefaultTag(ctx context.Context, db *database.Connection, i CreateDefaultTagInput) (*dtos.DefaultTag, error)
CreateDefaultTag creates a single tag in the default_tags table. Admin only.
func CreateEvidence ¶
func CreateEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i CreateEvidenceInput) (*dtos.Evidence, error)
func CreateEvidenceMetadata ¶
func CreateEvidenceMetadata(ctx context.Context, db *database.Connection, i EditEvidenceMetadataInput) error
func CreateFinding ¶
func CreateFinding(ctx context.Context, db *database.Connection, i CreateFindingInput) (*dtos.Finding, error)
func CreateFindingCategory ¶
func CreateFindingCategory(ctx context.Context, db *database.Connection, newCategory string) (*dtos.FindingCategory, error)
CreateFindingCategory adds a new finding category to the finding_categories table
func CreateGlobalVar ¶
func CreateGlobalVar(ctx context.Context, db *database.Connection, i CreateGlobalVarInput) (*dtos.GlobalVar, error)
func CreateHeadlessUser ¶
func CreateHeadlessUser(ctx context.Context, db *database.Connection, i CreateUserInput) (*dtos.CreateUserOutput, error)
CreateHeadlessUser is really just CreateUser. The difference here is that _headless_ users will not have authentication, and instead rely on user-impersonation and API keys for access.
func CreateOperation ¶
func CreateOperation(ctx context.Context, db *database.Connection, i CreateOperationInput) (*dtos.Operation, error)
func CreateOperationVar ¶
func CreateOperationVar(ctx context.Context, db *database.Connection, i CreateOperationVarInput) (*dtos.OperationVar, error)
func CreateQuery ¶
func CreateQuery(ctx context.Context, db *database.Connection, i CreateQueryInput) (*dtos.Query, error)
CreateQuery inserts a new query into the database
func CreateServiceWorker ¶
func CreateServiceWorker(ctx context.Context, db *database.Connection, i CreateServiceWorkerInput) error
func CreateTag ¶
func CreateTag(ctx context.Context, db *database.Connection, i CreateTagInput) (*dtos.Tag, error)
func CreateUser ¶
func CreateUser(db *database.Connection, i CreateUserInput) (*dtos.CreateUserOutput, error)
CreateUser generates an entry in the users table in the database. No more is done here, but it is expected that the caller will, at a minimum, also want to create an entry in the authentication tables, so that the user can actually log in.
Note: CreateUserInput.Slug is a _suggestion_, and it may be altered to ensure uniqueness.
Returns a structure containing both the true slug (i.e. what it was mangled to, if it was infact mangled), plus the associated user_id value
func CreateUserGroup ¶
func CreateUserGroup(ctx context.Context, db *database.Connection, i CreateUserGroupInput) (*dtos.UserGroup, error)
func DeleteAPIKey ¶
func DeleteAPIKey(ctx context.Context, db *database.Connection, i DeleteAPIKeyInput) error
func DeleteAuthScheme ¶
func DeleteAuthScheme(ctx context.Context, db *database.Connection, i DeleteAuthSchemeInput) error
DeleteAuthScheme removes a user's association with a particular auth_scheme. This function applies for both admin related actions and plain user actions. If UserSlug is not provided, this will apply to the requesting user. If it is provided, then this triggers admin validation, and will apply to the provided user matching the given slug.
func DeleteAuthSchemeUsers ¶
DeleteAuthSchemeUsers removes/unlinks all users from a provided scheme
func DeleteDefaultTag ¶
func DeleteDefaultTag(ctx context.Context, db *database.Connection, i DeleteDefaultTagInput) error
DeleteDefaultTag removes a single tag in the default_tags table by the tag id. Admin only.
func DeleteEvidence ¶
func DeleteEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i DeleteEvidenceInput) error
func DeleteFinding ¶
func DeleteFinding(ctx context.Context, db *database.Connection, i DeleteFindingInput) error
func DeleteFindingCategory ¶
func DeleteFindingCategory(ctx context.Context, db *database.Connection, i DeleteFindingCategoryInput) error
DeleteFindingCategory removes an entry from the finding_categories table
func DeleteGlobalVar ¶
func DeleteOperation ¶
func DeleteOperation(ctx context.Context, db *database.Connection, contentStore contentstore.Store, slug string) error
func DeleteOperationVar ¶
func DeleteQuery ¶
func DeleteQuery(ctx context.Context, db *database.Connection, i DeleteQueryInput) error
DeleteQuery removes a saved query for the given operation
func DeleteServiceWorker ¶
func DeleteServiceWorker(ctx context.Context, db *database.Connection, i DeleteServiceWorkerInput) error
func DeleteSessionsForUserSlug ¶
DeleteSessionsForUserSlug finds all existing sessions for a given user, then removes them, effectively logging the user out of the service.
func DeleteTag ¶
func DeleteTag(ctx context.Context, db *database.Connection, i DeleteTagInput) error
DeleteTag removes a tag and untags all evidence with the tag
func DeleteUser ¶
DeleteUser provides the ability for a super admin to remove a user from the system. Doing so removes access only. Evidence and other contributions remain. Note that users are not able to delete their own accounts to prevent accidents. Also note that once a user has been deleted, they cannot be restored.
func DeleteUserGroup ¶
func ListAPIKeys ¶
func ListActiveServices ¶
func ListActiveServices(ctx context.Context, db *database.Connection) ([]*dtos.ActiveServiceWorker, error)
func ListAuthDetails ¶
func ListAuthDetails(ctx context.Context, db *database.Connection, supportedAuthSchemes *[]dtos.SupportedAuthScheme) ([]*dtos.DetailedAuthenticationInfo, error)
func ListDefaultTags ¶
func ListDefaultTags(ctx context.Context, db *database.Connection) ([]*dtos.DefaultTag, error)
ListDefaultTags provides a list of all of the tags in the default_tags table. Admin only.
func ListEvidenceCreatorsForOperation ¶
func ListEvidenceCreatorsForOperation(ctx context.Context, db *database.Connection, i ListEvidenceCreatorsForOperationInput) ([]*dtos.User, error)
ListEvidenceCreatorsForOperation returns a list of all users that have (ever) created a piece of evidence for a given operation slug. Note that this won't return users that _had_ created evidence that has since been deleted
func ListEvidenceForFinding ¶
func ListEvidenceForFinding(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i ListEvidenceForFindingInput) ([]dtos.Evidence, error)
func ListEvidenceForOperation ¶
func ListEvidenceForOperation(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i ListEvidenceForOperationInput) ([]*dtos.Evidence, error)
ListEvidenceForOperation retrieves all evidence for a particular operation id matching a particular set of filters (e.g. tag:some_tag)
func ListFindingCategories ¶
func ListFindingCategories(ctx context.Context, db *database.Connection, includeDeleted bool) (interface{}, error)
ListFindingCategories retrieves a list of all of the finding categories present in the database.
func ListFindingsForOperation ¶
func ListFindingsForOperation(ctx context.Context, db *database.Connection, i ListFindingsForOperationInput) ([]*dtos.Finding, error)
func ListGlobalVars ¶
func ListOperationVars ¶
func ListOperationVars(ctx context.Context, db *database.Connection, operationSlug string) ([]*dtos.OperationVar, error)
func ListOperations ¶
ListOperations retrieves a list of all operations that the contextual user can see
func ListOperationsForAdmin ¶
func ListOperationsForAdmin(ctx context.Context, db *database.Connection) ([]*dtos.Operation, error)
ListOperationsForAdmin is a specialized version of ListOperations where no operations are filtered For use in admin screens only
func ListQueriesForOperation ¶
func ListQueriesForOperation(ctx context.Context, db *database.Connection, operationSlug string) ([]*dtos.Query, error)
ListQueriesForOperation retrieves all saved queries for a given operation id
func ListServiceWorker ¶
func ListServiceWorker(ctx context.Context, db *database.Connection) ([]*dtos.ServiceWorker, error)
func ListTagDifference ¶
func ListTagDifference(ctx context.Context, db *database.Connection, i ListTagsDifferenceInput) (*dtos.TagDifference, error)
ListTagDifference determines which tag values are common between two operations. This is done via relative comparison. That is, all of the tags in the "source" are compared against the "destination" returning only tags that are common, and tags that are in the source, but not in the destination. The opposite list (tags that exist in the destination, but not the source) is not generated.
func ListTagDifferenceForEvidence ¶
func ListTagDifferenceForEvidence(ctx context.Context, db *database.Connection, input ListTagDifferenceForEvidenceInput) (*dtos.TagDifference, error)
func ListTagsForOperation ¶
func ListTagsForOperation(ctx context.Context, db *database.Connection, i ListTagsForOperationInput) ([]*dtos.TagWithUsage, error)
func ListUserGroups ¶
func ListUserGroups(ctx context.Context, db *database.Connection, i ListUserGroupsInput) ([]*dtos.UserGroupAdminView, error)
lists all user groups that can be added to an operation
func ListUserGroupsForAdmin ¶
func ListUserGroupsForAdmin(ctx context.Context, db *database.Connection, i ListUserGroupsForAdminInput) ([]dtos.UserGroupAdminView, error)
Lists all usergroups for an admin, with pagination
func ListUserGroupsForOperation ¶
func ListUserGroupsForOperation(ctx context.Context, db *database.Connection, i ListUserGroupsForOperationInput) ([]*dtos.UserGroupOperationRole, error)
Lists all user groups for an operation; op admins and sys admins can view
func ListUsers ¶
func ListUsers(ctx context.Context, db *database.Connection, i ListUsersInput) ([]*dtos.User, error)
func ListUsersForAdmin ¶
func ListUsersForAdmin(ctx context.Context, db *database.Connection, i ListUsersForAdminInput) (*dtos.PaginationWrapper, error)
ListUsersForAdmin retreives standard User (public) details, and aguments with some particular fields meant for admin review. For use in admin views only.
func ListUsersForOperation ¶
func ListUsersForOperation(ctx context.Context, db *database.Connection, i ListUsersForOperationInput) ([]*dtos.UserOperationRole, error)
func LookupGlobalVar ¶
func LookupOperationVar ¶
func LookupOperationVar(db *database.Connection, varSlug string) (*models.OperationVar, error)
func MergeDefaultTags ¶
func MergeDefaultTags(ctx context.Context, db *database.Connection, i []CreateDefaultTagInput) error
func ModifyUserGroup ¶
func ModifyUserGroup(ctx context.Context, db *database.Connection, i ModifyUserGroupInput) (*dtos.UserGroup, error)
func MoveEvidence ¶
func MoveEvidence(ctx context.Context, db *database.Connection, i MoveEvidenceInput) error
func ReadEvidenceMetadata ¶
func ReadEvidenceMetadata(ctx context.Context, db *database.Connection, i ReadEvidenceMetadataInput) ([]*dtos.EvidenceMetadata, error)
func ReadFinding ¶
func ReadFinding(ctx context.Context, db *database.Connection, i ReadFindingInput) (*dtos.Finding, error)
func ReadOperation ¶
func ReadUser ¶
func ReadUser(ctx context.Context, db *database.Connection, userSlug string, supportedAuthSchemes *[]dtos.SupportedAuthScheme) (*dtos.UserOwnView, error)
ReadUser retrieves a detailed view of a user. This is separate from the data retriving by listing users, or reading another user's profile (when not an admin)
func RunServiceWorker ¶
func RunServiceWorker(ctx context.Context, db *database.Connection, i RunServiceWorkerInput) error
func SanitizeSlug ¶
SanitizeOperationSlug removes objectionable characters from a slug and returns the new slug. Current logic: only allow alphanumeric characters and hyphen, with hypen excluded at the start and end
func SelfOrSlugToUserID ¶
func SendURLData ¶
func SendURLData(ctx context.Context, db *database.Connection, contentStore *contentstore.S3Store, i ReadEvidenceInput) (*contentstore.URLData, error)
func SetFavoriteOperation ¶
func SetFavoriteOperation(ctx context.Context, db *database.Connection, i SetFavoriteInput) error
func SetUserFlags ¶
func SetUserFlags(ctx context.Context, db *database.Connection, i SetUserFlagsInput) error
SetUserFlags updates flags for the indicated user, namely: admin and disabled. Then removes all sessions for that user (logging them out)
NOTE: The flag is to _disable_ the user, which prevents access. To enable a user, set Disabled=false
func SetUserGroupOperationRole ¶
func SetUserGroupOperationRole(ctx context.Context, db *database.Connection, i SetUserGroupOperationRoleInput) error
func SetUserOperationRole ¶
func SetUserOperationRole(ctx context.Context, db *database.Connection, i SetUserOperationRoleInput) error
func SortUsersInToGroups ¶
func SortUsersInToGroups(slugMap SlugMap) ([]dtos.UserGroupAdminView, error)
func TestServiceWorker ¶
func TestServiceWorker(ctx context.Context, db *database.Connection, serviceWorkerID int64) (*dtos.ServiceWorkerTestOutput, error)
func UpdateDefaultTag ¶
func UpdateDefaultTag(ctx context.Context, db *database.Connection, i UpdateDefaultTagInput) error
func UpdateEvidence ¶
func UpdateEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i UpdateEvidenceInput) error
func UpdateEvidenceMetadata ¶
func UpdateEvidenceMetadata(ctx context.Context, db *database.Connection, i EditEvidenceMetadataInput) error
func UpdateFinding ¶
func UpdateFinding(ctx context.Context, db *database.Connection, i UpdateFindingInput) error
func UpdateFindingCategory ¶
func UpdateFindingCategory(ctx context.Context, db *database.Connection, i UpdateFindingCategoryInput) error
UpdateFindingCategory updates the specified entry in the finding_categories table
func UpdateGlobalVar ¶
func UpdateGlobalVar(ctx context.Context, db *database.Connection, i UpdateGlobalVarInput) error
func UpdateOperation ¶
func UpdateOperation(ctx context.Context, db *database.Connection, i UpdateOperationInput) error
func UpdateOperationVar ¶
func UpdateOperationVar(ctx context.Context, db *database.Connection, i UpdateOperationVarInput) error
func UpdateQuery ¶
func UpdateQuery(ctx context.Context, db *database.Connection, i UpdateQueryInput) error
UpdateQuery modifies a query for the given operation
func UpdateServiceWorker ¶
func UpdateServiceWorker(ctx context.Context, db *database.Connection, i UpdateServiceWorkerInput) error
func UpdateTag ¶
func UpdateTag(ctx context.Context, db *database.Connection, i UpdateTagInput) error
UpdateTag updates a tag's name and color
func UpdateUserProfile ¶
func UpdateUserProfile(ctx context.Context, db *database.Connection, i UpdateUserProfileInput) error
func UpsertEvidenceMetadata ¶
func UpsertEvidenceMetadata(ctx context.Context, db *database.Connection, i UpsertEvidenceMetadataInput) error
func UpsertQuery ¶
func UpsertQuery(ctx context.Context, db *database.Connection, i UpsertQueryInput) (*dtos.Query, error)
Types ¶
type CreateDefaultTagInput ¶
type CreateEvidenceInput ¶
type CreateFindingInput ¶
type CreateGlobalVarInput ¶
type CreateOperationInput ¶
type CreateOperationVarInput ¶
type CreateQueryInput ¶
CreateQueryInput provides a structure that holds the values needed to generate a new saved query
type CreateTagInput ¶
type CreateUserGroupInput ¶
type CreateUserInput ¶
type DeleteAPIKeyInput ¶
type DeleteAuthSchemeInput ¶
type DeleteDefaultTagInput ¶
type DeleteDefaultTagInput struct {
ID int64
}
type DeleteEvidenceInput ¶
type DeleteFindingInput ¶
type DeleteGlobalVarInput ¶
type DeleteGlobalVarInput struct {
Name string
}
type DeleteOperationVarInput ¶
type DeleteOperationVarInput struct {
Name string
}
type DeleteQueryInput ¶
type DeleteTagInput ¶
type EvidenceCountWithID ¶
type EvidenceCountWithID struct { dtos.EvidenceCount OperationID int64 `db:"operation_id" json:"operationId"` }
type ExpandedTagUsageData ¶
type ListEvidenceCreatorsForOperationInput ¶
type ListEvidenceCreatorsForOperationInput struct {
OperationSlug string
}
type ListEvidenceForOperationInput ¶
type ListEvidenceForOperationInput struct { OperationSlug string Filters helpers.TimelineFilters }
type ListFindingsForOperationInput ¶
type ListFindingsForOperationInput struct { OperationSlug string Filters helpers.TimelineFilters }
type ListTagDifferenceForEvidenceInput ¶
type ListTagDifferenceForEvidenceInput struct { ListTagsDifferenceInput SourceEvidenceUUID string }
type ListTagsDifferenceInput ¶
type ListTagsForOperationInput ¶
type ListTagsForOperationInput struct {
OperationSlug string
}
type ListUserGroupsForAdminInput ¶
type ListUserGroupsForAdminInput struct { UserGroupFilter IncludeDeleted bool }
type ListUserGroupsForOperationInput ¶
type ListUserGroupsForOperationInput struct { UserGroupFilter OperationSlug string }
type ListUserGroupsInput ¶
type ListUsersForAdminInput ¶
type ListUsersForAdminInput struct { UserFilter Pagination IncludeDeleted bool }
type ListUsersForOperationInput ¶
type ListUsersForOperationInput struct { Pagination UserFilter OperationSlug string }
type ListUsersInput ¶
type ModifyUserGroupInput ¶
type MoveEvidenceInput ¶
type OperationWithID ¶
type Pagination ¶
type Pagination struct { PageSize int64 Page int64 TotalCount int64 // contains filtered or unexported fields }
func ParseRequestQueryPagination ¶
func ParseRequestQueryPagination(dr dissectors.DissectedRequest, defaultMaxItems int64) Pagination
ParseRequestQueryPagination retreives the part of the request set aside for pagination Note that this retrieves the values and hopes for the best. Since this uses a DissectedRequest, it is the caller of the function to ensure no error occurred _after_ this has been called.
func (*Pagination) Select ¶
func (p *Pagination) Select(ctx context.Context, db *database.Connection, resultSlice interface{}, sb sq.SelectBuilder) error
Select is a wrapper around database.Connection.Select. This performs a query that returns multiple rows. In addition, this counts the total number of rows matching this query, and saves the result inside the pagination structure.
This actually performs two queries: the intended query, plus a second query to discover the total number of matching rows. I think this works differently in other databases, but this seems to be the preferred route for mysql. See: https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_found-rows for more details
Note: It is possible to have the initial query succeed and the count query to fail. In order to prevent odd issues, you should always do an error check before using the resulting value.
Note 2: This is really only useful for communicating size back to the enduser. For other pagination techniques, you may want to use LIMIT and OFFSET directly
func (*Pagination) SetMaxItems ¶
func (p *Pagination) SetMaxItems(maxItems int64) *Pagination
SetMaxItems sets the maximum number of items that can be returned in a request/page. This must be called before Select to have any effect
func (*Pagination) WrapData ¶
func (p *Pagination) WrapData(data interface{}) *dtos.PaginationWrapper
WrapData is a small helper to turn the desired content of a request into a pagination result set
type ReadEvidenceInput ¶
type ReadEvidenceOutput ¶
type ReadEvidenceOutput struct { UUID string `json:"uuid"` Description string `json:"description"` ContentType string `json:"contentType"` OccurredAt time.Time `json:"occurredAt"` AdjustedAt *time.Time `json:"adjustedAt"` Preview io.Reader `json:"-"` Media io.Reader `json:"-"` }
func ReadEvidence ¶
func ReadEvidence(ctx context.Context, db *database.Connection, contentStore contentstore.Store, i ReadEvidenceInput) (*ReadEvidenceOutput, error)
type ReadFindingInput ¶
type RunServiceWorkerInput ¶
type SetFavoriteInput ¶
type SetUserFlagsInput ¶
type SetUserGroupOperationRoleInput ¶
type SetUserGroupOperationRoleInput struct { OperationSlug string UserGroupSlug string Role policy.OperationRole }
type SetUserOperationRoleInput ¶
type SetUserOperationRoleInput struct { OperationSlug string UserSlug string Role policy.OperationRole }
type SlugMap ¶
type SlugMap []struct { UserSlug sql.NullString `db:"user_slug"` GroupSlug string `db:"group_slug"` GroupName string `db:"group_name"` Deleted sql.NullString `db:"deleted"` }
func GetSlugMap ¶
func GetSlugMap(db *database.Connection, i ListUserGroupsForAdminInput) (SlugMap, error)
type TagUsageItem ¶
type TopContribWithID ¶
type TopContribWithID struct { dtos.TopContrib OperationID int64 `db:"operation_id" json:"operationId"` }
type UpdateDefaultTagInput ¶
type UpdateEvidenceInput ¶
type UpdateFindingInput ¶
type UpdateGlobalVarInput ¶
type UpdateOperationInput ¶
type UpdateOperationVarInput ¶
type UpdateQueryInput ¶
type UpdateTagInput ¶
type UpdateUserProfileInput ¶
type UpsertEvidenceMetadataInput ¶
type UpsertEvidenceMetadataInput struct { EditEvidenceMetadataInput Status string Message *string CanProcess *bool }
type UpsertQueryInput ¶
type UpsertQueryInput struct { CreateQueryInput ReplaceName bool }
type UserFilter ¶
UserFilter provides a mechanism to alter queries such that users are filtered
func ParseRequestQueryUserFilter ¶
func ParseRequestQueryUserFilter(dr dissectors.DissectedRequest) UserFilter
ParseRequestQueryUserFilter generates a UserFilter object from a given request. This expects that filtering is specified by the query parameter "name"
func (*UserFilter) AddWhere ¶
func (uf *UserFilter) AddWhere(sb *sq.SelectBuilder)
AddWhere adds to the given SelectBuilder a Where clause that will apply the filtering
type UserGroupFilter ¶
UserFilter provides a mechanism to alter queries such that users are filtered
func ParseRequestQueryUserGroupFilter ¶
func ParseRequestQueryUserGroupFilter(dr dissectors.DissectedRequest) UserGroupFilter
ParseRequestQueryUserFilter generates a UserFilter object from a given request. This expects that filtering is specified by the query parameter "name"
func (*UserGroupFilter) AddWhere ¶
func (uf *UserGroupFilter) AddWhere(sb *sq.SelectBuilder)
AddWhere adds to the given SelectBuilder a Where clause that will apply the filtering
Source Files ¶
- api_key.go
- auth_scheme.go
- evidence.go
- evidence_metadata.go
- finding.go
- finding_category.go
- global_vars.go
- helpers.go
- operation_role.go
- operation_vars.go
- operations.go
- queries.go
- service_helper_user_filter.go
- service_helper_user_group_filter.go
- service_pagination_helper.go
- service_worker.go
- tag.go
- testing_helpers.go
- user.go
- user_groups.go