Documentation
¶
Index ¶
- Variables
- func ParseComposerLock(pathToLockfile string) ([]lockfile.PackageDetails, error)
- type ComposerLock
- type ComposerLockExtractor
- func (e ComposerLockExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
- func (e ComposerLockExtractor) IsOfficiallySupported() bool
- func (e ComposerLockExtractor) PackageManager() models.PackageManager
- func (e ComposerLockExtractor) ShouldExtract(path string) bool
- type ComposerMatcher
- type ComposerMatcherDependencyMap
- type ComposerPackage
Constants ¶
This section is empty.
Variables ¶
var ComposerExtractor = ComposerLockExtractor{ lockfile.WithMatcher{Matchers: []lockfile.Matcher{&ComposerMatcher{}}}, }
Functions ¶
func ParseComposerLock ¶
func ParseComposerLock(pathToLockfile string) ([]lockfile.PackageDetails, error)
Types ¶
type ComposerLock ¶
type ComposerLock struct {
Packages []ComposerPackage `json:"packages"`
PackagesDev []ComposerPackage `json:"packages-dev"`
}
type ComposerLockExtractor ¶
type ComposerLockExtractor struct {
lockfile.WithMatcher
}
func (ComposerLockExtractor) Extract ¶
func (e ComposerLockExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
func (ComposerLockExtractor) IsOfficiallySupported ¶
func (e ComposerLockExtractor) IsOfficiallySupported() bool
func (ComposerLockExtractor) PackageManager ¶
func (e ComposerLockExtractor) PackageManager() models.PackageManager
func (ComposerLockExtractor) ShouldExtract ¶
func (e ComposerLockExtractor) ShouldExtract(path string) bool
type ComposerMatcher ¶
type ComposerMatcher struct{}
func (ComposerMatcher) GetSourceFile ¶
func (ComposerMatcher) Match ¶
func (matcher ComposerMatcher) Match(sourceFile lockfile.DepFile, packages []lockfile.PackageDetails, context lockfile.ScanContext) error
Match works by leveraging the json decoder to only parse json sections of interest (e.g dependencies) Whenever the json decoder try to deserialize a file, it will look at json sections it needs to deserialize and then call the proper UnmarshallJSON method of the type. As the JSON decoder expect us to only deserialize it, not trying to find the exact location in the file of the content, it does not provide us buffer information (offset, file path, etc...)
To work around this limitation, we are pre-filling the structure with all the field we will need during the deserialization :
- The root type to know which json section we are deserializing
- The file path to be able to fill properly location fields of lockfile.PackageDetails
- The line offset to be able to compute the line of any found dependencies in the file
- And a list of pointer to the original lockfile.PackageDetails extracted by the parser to be able to modify them with the json section content
type ComposerMatcherDependencyMap ¶
type ComposerMatcherDependencyMap struct {
lockfile.MatcherDependencyMap
}
ComposerMatcherDependencyMap is here to have access to all lockfile.MatcherDependencyMap methods and at the same time having a different type to have a clear UnmarshallJSON method for the json decoder and avoid overlaps with other matchers.
func (*ComposerMatcherDependencyMap) UnmarshalJSON ¶
func (depMap *ComposerMatcherDependencyMap) UnmarshalJSON(bytes []byte) error