filecrawler

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const OOXMLCustomPropertiesFile = "docProps/custom.xml"

OOXMLCustomPropertiesFile is the relative path to the metadata file of every Office file where the custom properties (also the sensitivity-labels of the MS Information Protection) are stored

Variables

This section is empty.

Functions

This section is empty.

Types

type Crawler

type Crawler struct {
	// contains filtered or unexported fields
}

The main crawler struct

func NewCrawler

func NewCrawler(
	logger utils.Logger,
	maxDepth int,
	excludedFolders map[string]struct{},
	excludedExtensions map[string]struct{},
	excludedLastModifiedBelow time.Time,
	excludedFileSizeBelow int64,
	onlyAccessibleFiles bool,
	threads int,
	deadline time.Time,
) *Crawler

func (*Crawler) Crawl

func (c *Crawler) Crawl(entryPoint *EntryPoint) *Result

Crawl crawls the filesystem begging by the given entry point. For every element it discovers, a new porcessing task is generated, back-feeding the crawler.

type EntryPoint

type EntryPoint struct {
	Path      string
	Share     string // The share in which the object is located
	IsShare   bool   // Marks if the crawled object itself is the share
	InsideDfs bool
}

The start information of every crawl

type File

type File struct {
	Share           string
	Path            string
	Name            string
	Extension       string // Without "."
	Mime            string
	Readable        bool
	Writable        bool
	Flags           string // Unix Permission bits and special file flags, such as setuid/setgid, sticky bit...
	SizeKb          int64
	LastModified    time.Time
	Depth           int
	IsSymlink       bool
	Properties      []string
	IsDfs           bool     // Windows exclusive
	NfsRestrictions []string // Linux exclusive
}

type OOXMLProperties

type OOXMLProperties struct {
	XMLName    xml.Name        `xml:"Properties"` // Important when adding attributes, always use uppercase for it, otherwise unmarshalling might not work
	Properties []OOXMLProperty `xml:"property"`
}

OOXMLProperties mirrors the xml structure of custom property metadata of Open Office Files

type OOXMLProperty

type OOXMLProperty struct {
	Fmtid    string  `xml:"fmtid,attr"`
	Pid      string  `xml:"pid,attr"`
	Name     string  `xml:"name,attr"`
	ValStr   *string `xml:"lpwstr"`
	ValInt   *string `xml:"i4"`
	ValDate  *string `xml:"filetime"`
	ValBool  *string `xml:"bool"`
	ValFloat *string `xml:"r8"`
}

func (*OOXMLProperty) GetVal

func (p *OOXMLProperty) GetVal() string

GetVal checks which tag was used for the property and returns its value as string

type Result

type Result struct {
	FoldersReadable int
	FilesReadable   int
	FilesWritable   int
	Data            []*File
	Status          string // Final scan status (success or graceful error). Should be stored along with the scan results.
	Exception       bool   // Indicates if something went wrong badly and results shall be discarded. This should never be

}

Jump to

Keyboard shortcuts

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