Class: Dependabot::DockerCompose::FileParser
Constant Summary
collapse
- ENV_VAR =
/\${(?<variable_name>[^}:]+)(?:\:-(?<default_value>[^}]+))?}/
- DIGEST =
/(?<digest>[0-9a-f]{64})/
- IMAGE_REGEX =
%r{^(#{REGISTRY}/)?#{IMAGE}#{TAG}?(?:@sha256:#{DIGEST})?#{NAME}?}x
- FROM =
/FROM/i
- PLATFORM =
/--platform\=(?<platform>\S+)/
- FROM_LINE =
%r{^#{FROM}\s+(#{PLATFORM}\s+)?(#{REGISTRY}/)?
#{IMAGE}#{TAG}?(?:@sha256:#{DIGEST})?#{NAME}?}x
Shared::SharedFileParser::DOMAIN, Shared::SharedFileParser::DOMAIN_COMPONENT, Shared::SharedFileParser::IMAGE, Shared::SharedFileParser::NAME, Shared::SharedFileParser::NAME_COMPONENT, Shared::SharedFileParser::REGISTRY, Shared::SharedFileParser::TAG
Instance Method Summary
collapse
Instance Method Details
#ecosystem ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/dependabot/docker_compose/file_parser.rb', line 25
def ecosystem
@ecosystem ||= T.let(
Ecosystem.new(
name: ECOSYSTEM,
package_manager: DockerPackageManager.new
),
T.nilable(Ecosystem)
)
end
|
#parse ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/dependabot/docker_compose/file_parser.rb', line 36
def parse
dependency_set = DependencySet.new
composefiles.each do |composefile|
yaml = YAML.safe_load(T.must(composefile.content), aliases: true)
next unless yaml["services"].is_a?(Hash)
yaml["services"].each do |_, service|
next unless service.is_a?(Hash)
parsed_from_image = parse_image_spec(service)
next unless parsed_from_image
parsed_from_image["registry"] = nil if parsed_from_image["registry"] == "docker.io"
version = version_from(parsed_from_image)
next unless version
dependency_set << build_dependency(composefile, parsed_from_image, version)
end
end
dependency_set.dependencies
end
|