File size: 26,344 Bytes
e98c0d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | # typed: strict
# frozen_string_literal: true
require "sorbet-runtime"
require "dependabot/utils"
# rubocop:disable Metrics/ModuleLength
module Dependabot
extend T::Sig
module ErrorAttributes
BACKTRACE = "error-backtrace"
CLASS = "error-class"
DETAILS = "error-details"
FINGERPRINT = "fingerprint"
MESSAGE = "error-message"
DEPENDENCIES = "job-dependencies"
DEPENDENCY_GROUPS = "job-dependency-groups"
JOB_ID = "job-id"
PACKAGE_MANAGER = "package-manager"
SECURITY_UPDATE = "security-update"
end
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/CyclomaticComplexity
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.fetcher_error_details(error)
case error
when Dependabot::ToolVersionNotSupported
{
"error-type": "tool_version_not_supported",
"error-detail": {
"tool-name": error.tool_name,
"detected-version": error.detected_version,
"supported-versions": error.supported_versions
}
}
when Dependabot::ToolFeatureNotSupported
{
"error-type": "tool_feature_not_supported",
"error-detail": {
"tool-name": error.tool_name,
"tool-type": error.tool_type,
feature: error.feature
}
}
when Dependabot::BranchNotFound
{
"error-type": "branch_not_found",
"error-detail": {
"branch-name": error.branch_name,
message: error.message
}
}
when Dependabot::DirectoryNotFound
{
"error-type": "directory_not_found",
"error-detail": { "directory-name": error.directory_name }
}
when Dependabot::RepoNotFound
# This happens if the repo gets removed after a job gets kicked off.
# This also happens when a configured personal access token is not authz'd to fetch files from the job repo.
{
"error-type": "job_repo_not_found",
"error-detail": { message: error.message }
}
when Dependabot::DependencyFileNotParseable
{
"error-type": "dependency_file_not_parseable",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::DependencyFileNotFound
{
"error-type": "dependency_file_not_found",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::OutOfDisk
{
"error-type": "out_of_disk",
"error-detail": {}
}
when Dependabot::PathDependenciesNotReachable
{
"error-type": "path_dependencies_not_reachable",
"error-detail": { dependencies: error.dependencies }
}
when Dependabot::PrivateSourceAuthenticationFailure
{
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Dependabot::DependencyNotFound
{
"error-type": "dependency_not_found",
"error-detail": { source: error.source }
}
when Octokit::Unauthorized
{ "error-type": "octokit_unauthorized" }
when Octokit::ServerError
# If we get a 500 from GitHub there's very little we can do about it,
# and responsibility for fixing it is on them, not us. As a result we
# quietly log these as errors
{ "error-type": "server_error" }
when BadRequirementError
{
"error-type": "illformed_requirement",
"error-detail": { message: error.message }
}
when *Octokit::RATE_LIMITED_ERRORS
# If we get a rate-limited error we let dependabot-api handle the
# retry by re-enqueing the update job after the reset
{
"error-type": "octokit_rate_limited",
"error-detail": {
"rate-limit-reset": T.cast(error, Octokit::Error).response_headers["X-RateLimit-Reset"]
}
}
end
end
# rubocop:enable Metrics/CyclomaticComplexity
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.parser_error_details(error)
case error
when Dependabot::ToolFeatureNotSupported
{
"error-type": "tool_feature_not_supported",
"error-detail": {
"tool-name": error.tool_name,
"tool-type": error.tool_type,
feature: error.feature
}
}
when Dependabot::DependencyFileNotEvaluatable
{
"error-type": "dependency_file_not_evaluatable",
"error-detail": { message: error.message }
}
when Dependabot::DependencyFileNotResolvable
{
"error-type": "dependency_file_not_resolvable",
"error-detail": { message: error.message }
}
when Dependabot::BranchNotFound
{
"error-type": "branch_not_found",
"error-detail": {
"branch-name": error.branch_name,
message: error.message
}
}
when Dependabot::DependencyFileNotParseable
{
"error-type": "dependency_file_not_parseable",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::DependencyFileNotFound
{
"error-type": "dependency_file_not_found",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::PathDependenciesNotReachable
{
"error-type": "path_dependencies_not_reachable",
"error-detail": { dependencies: error.dependencies }
}
when Dependabot::PrivateSourceAuthenticationFailure
{
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Dependabot::GitDependenciesNotReachable
{
"error-type": "git_dependencies_not_reachable",
"error-detail": { "dependency-urls": error.dependency_urls }
}
when Dependabot::NotImplemented
{
"error-type": "not_implemented",
"error-detail": {
message: error.message
}
}
when Octokit::ServerError
# If we get a 500 from GitHub there's very little we can do about it,
# and responsibility for fixing it is on them, not us. As a result we
# quietly log these as errors
{ "error-type": "server_error" }
end
end
# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/AbcSize
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.updater_error_details(error)
case error
when Dependabot::ToolFeatureNotSupported
{
"error-type": "tool_feature_not_supported",
"error-detail": {
"tool-name": error.tool_name,
"tool-type": error.tool_type,
feature: error.feature
}
}
when Dependabot::DependencyFileNotResolvable
{
"error-type": "dependency_file_not_resolvable",
"error-detail": { message: error.message }
}
when Dependabot::DependencyFileNotEvaluatable
{
"error-type": "dependency_file_not_evaluatable",
"error-detail": { message: error.message }
}
when Dependabot::DependencyFileNotParseable
{
"error-type": "dependency_file_not_parseable",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::DependencyFileNotSupported
{
"error-type": "dependency_file_not_supported",
"error-detail": { message: error.message }
}
when Dependabot::GitDependenciesNotReachable
{
"error-type": "git_dependencies_not_reachable",
"error-detail": { "dependency-urls": error.dependency_urls }
}
when Dependabot::DependencyFileNotFound
{
"error-type": "dependency_file_not_found",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::DependencyFileContentNotChanged
{
"error-type": "dependency_file_content_not_changed",
"error-detail": { message: error.message }
}
when Dependabot::ToolVersionNotSupported
{
"error-type": "tool_version_not_supported",
"error-detail": {
"tool-name": error.tool_name,
"detected-version": error.detected_version,
"supported-versions": error.supported_versions
}
}
when Dependabot::MisconfiguredTooling
{
"error-type": "misconfigured_tooling",
"error-detail": { "tool-name": error.tool_name, message: error.tool_message }
}
when Dependabot::GitDependencyReferenceNotFound
{
"error-type": "git_dependency_reference_not_found",
"error-detail": { dependency: error.dependency }
}
when Dependabot::PrivateSourceAuthenticationFailure
{
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Dependabot::DependencyNotFound
{
"error-type": "dependency_not_found",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceTimedOut
{
"error-type": "private_source_timed_out",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceCertificateFailure
{
"error-type": "private_source_certificate_failure",
"error-detail": { source: error.source }
}
when Dependabot::MissingEnvironmentVariable
{
"error-type": "missing_environment_variable",
"error-detail": {
"environment-variable": error.environment_variable,
"error-message": error.message
}
}
when Dependabot::OutOfDisk
{
"error-type": "out_of_disk",
"error-detail": {}
}
when Dependabot::GoModulePathMismatch
{
"error-type": "go_module_path_mismatch",
"error-detail": {
"declared-path": error.declared_path,
"discovered-path": error.discovered_path,
"go-mod": error.go_mod
}
}
when Dependabot::UpdateNotPossible
{
"error-type": "update_not_possible",
"error-detail": {
dependencies: error.dependencies
}
}
when BadRequirementError
{
"error-type": "illformed_requirement",
"error-detail": { message: error.message }
}
when RegistryError
{
"error-type": "registry_error",
"error-detail": { status: error.status,
msg: error.message }
}
when
IncompatibleCPU,
NetworkUnsafeHTTP,
SnapshotsUnavailableGraphError
error.detail
when Dependabot::NotImplemented
{
"error-type": "not_implemented",
"error-detail": {
message: error.message
}
}
when Dependabot::InvalidGitAuthToken
{
"error-type": "git_token_auth_error",
"error-detail": { message: error.message }
}
when *Octokit::RATE_LIMITED_ERRORS
# If we get a rate-limited error we let dependabot-api handle the
# retry by re-enqueing the update job after the reset
{
"error-type": "octokit_rate_limited",
"error-detail": {
"rate-limit-reset": T.cast(error, Octokit::Error).response_headers["X-RateLimit-Reset"]
}
}
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Lint/RedundantCopDisableDirective
# rubocop:enable Metrics/AbcSize
class DependabotError < StandardError
extend T::Sig
BASIC_AUTH_REGEX = %r{://(?<auth>[^:@]*:[^@%\s/]+(@|%40))}
# Remove any path segment from fury.io sources
FURY_IO_PATH_REGEX = %r{fury\.io/(?<path>.+)}
sig { params(message: T.any(T.nilable(String), MatchData)).void }
def initialize(message = nil)
super(sanitize_message(message))
end
private
sig { params(message: T.any(T.nilable(String), MatchData)).returns(T.any(T.nilable(String), MatchData)) }
def sanitize_message(message)
return message unless message.is_a?(String)
path_regex =
Regexp.escape(Utils::BUMP_TMP_DIR_PATH) + "\\/" +
Regexp.escape(Utils::BUMP_TMP_FILE_PREFIX) + "[a-zA-Z0-9-]*"
message = message.gsub(/#{path_regex}/, "dependabot_tmp_dir").strip
filter_sensitive_data(message)
end
sig { params(message: String).returns(String) }
def filter_sensitive_data(message)
replace_capture_groups(message, BASIC_AUTH_REGEX, "")
end
sig { params(source: String).returns(String) }
def sanitize_source(source)
source = filter_sensitive_data(source)
replace_capture_groups(source, FURY_IO_PATH_REGEX, "<redacted>")
end
sig do
params(
string: String,
regex: Regexp,
replacement: String
).returns(String)
end
def replace_capture_groups(string, regex, replacement)
string.scan(regex).flatten.compact.reduce(string) do |original_msg, match|
original_msg.gsub(match, replacement)
end
end
end
class TypedDependabotError < Dependabot::DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :error_type
sig { params(error_type: String, message: T.any(T.nilable(String), MatchData)).void }
def initialize(error_type, message = nil)
@error_type = T.let(error_type, String)
super(message || error_type)
end
sig { params(hash: T.nilable(T::Hash[Symbol, T.untyped])).returns(T::Hash[Symbol, T.untyped]) }
def detail(hash = nil)
{
"error-type": error_type,
"error-detail": hash || {
message: message
}
}
end
end
class OutOfDisk < DependabotError; end
class OutOfMemory < DependabotError; end
class NotImplemented < DependabotError; end
class InvalidGitAuthToken < DependabotError; end
#####################
# Repo level errors #
#####################
class DirectoryNotFound < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :directory_name
sig { params(directory_name: String, msg: T.nilable(String)).void }
def initialize(directory_name, msg = nil)
@directory_name = directory_name
super(msg)
end
end
class BranchNotFound < DependabotError
extend T::Sig
sig { returns(T.nilable(String)) }
attr_reader :branch_name
sig { params(branch_name: T.nilable(String), msg: T.nilable(String)).void }
def initialize(branch_name, msg = nil)
@branch_name = branch_name
super(msg)
end
end
class RepoNotFound < DependabotError
extend T::Sig
sig { returns(T.any(Dependabot::Source, String)) }
attr_reader :source
sig { params(source: T.any(Dependabot::Source, String), msg: T.nilable(String)).void }
def initialize(source, msg = nil)
@source = source
super(msg)
end
end
#####################
# File level errors #
#####################
class MisconfiguredTooling < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :tool_name
sig { returns(String) }
attr_reader :tool_message
sig do
params(
tool_name: String,
tool_message: String
).void
end
def initialize(tool_name, tool_message)
@tool_name = tool_name
@tool_message = tool_message
msg = "Dependabot detected that #{tool_name} is misconfigured in this repository. " \
"Running `#{tool_name.downcase}` results in the following error: #{tool_message}"
super(msg)
end
end
class ToolVersionNotSupported < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :tool_name
sig { returns(String) }
attr_reader :detected_version
sig { returns(String) }
attr_reader :supported_versions
sig do
params(
tool_name: String,
detected_version: String,
supported_versions: String
).void
end
def initialize(tool_name, detected_version, supported_versions)
@tool_name = tool_name
@detected_version = detected_version
@supported_versions = supported_versions
msg = "Dependabot detected the following #{tool_name} requirement for your project: '#{detected_version}'." \
"\n\nCurrently, the following #{tool_name} versions are supported in Dependabot: #{supported_versions}."
super(msg)
end
end
class ToolFeatureNotSupported < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :tool_name, :tool_type, :feature
sig do
params(
tool_name: String,
tool_type: String,
feature: String
).void
end
def initialize(tool_name:, tool_type:, feature:)
@tool_name = tool_name
@tool_type = tool_type
@feature = feature
super(build_message)
end
private
sig { returns(String) }
def build_message
"Dependabot doesn't support the feature '#{feature}' for #{tool_name} (#{tool_type}). " \
"Please refer to the documentation for supported features."
end
end
class DependencyFileNotFound < DependabotError
extend T::Sig
sig { returns(T.nilable(String)) }
attr_reader :file_path
sig { params(file_path: T.nilable(String), msg: T.nilable(String)).void }
def initialize(file_path, msg = nil)
@file_path = file_path
super(msg || "#{file_path} not found")
end
sig { returns(T.nilable(String)) }
def file_name
return unless file_path
T.must(file_path).split("/").last
end
sig { returns(T.nilable(String)) }
def directory
# Directory should always start with a `/`
return unless file_path
T.must(T.must(file_path).split("/")[0..-2]).join("/").sub(%r{^/*}, "/")
end
end
class DependencyFileNotParseable < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :file_path
sig { params(file_path: String, msg: T.nilable(String)).void }
def initialize(file_path, msg = nil)
@file_path = file_path
super(msg || "#{file_path} not parseable")
end
sig { returns(String) }
def file_name
T.must(file_path.split("/").last)
end
sig { returns(String) }
def directory
# Directory should always start with a `/`
T.must(file_path.split("/")[0..-2]).join("/").sub(%r{^/*}, "/")
end
end
class DependencyFileNotEvaluatable < DependabotError; end
class DependencyFileNotResolvable < DependabotError; end
class DependencyFileNotSupported < DependabotError; end
class DependencyFileContentNotChanged < DependabotError; end
class BadRequirementError < Gem::Requirement::BadRequirementError; end
#######################
# Source level errors #
#######################
class PrivateSourceAuthenticationFailure < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: T.nilable(String)).void }
def initialize(source)
@source = T.let(sanitize_source(T.must(source)), String)
msg = "The following source could not be reached as it requires " \
"authentication (and any provided details were invalid or lacked " \
"the required permissions): #{@source}"
super(msg)
end
end
class PrivateSourceBadResponse < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: T.nilable(String)).void }
def initialize(source)
@source = T.let(sanitize_source(T.must(source)), String)
msg = "Bad response error while accessing source: #{@source}"
super(msg)
end
end
class PrivateSourceTimedOut < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: String).void }
def initialize(source)
@source = T.let(sanitize_source(source), String)
super("The following source timed out: #{@source}")
end
end
class PrivateSourceCertificateFailure < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: String).void }
def initialize(source)
@source = T.let(sanitize_source(source), String)
super("Could not verify the SSL certificate for #{@source}")
end
end
class MissingEnvironmentVariable < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :environment_variable
sig { returns(String) }
attr_reader :message
sig { params(environment_variable: String, message: String).void }
def initialize(environment_variable, message = "")
@environment_variable = environment_variable
@message = message
super("Missing environment variable #{@environment_variable}. #{@message}")
end
end
class DependencyNotFound < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: T.nilable(String)).void }
def initialize(source)
@source = T.let(sanitize_source(T.must(source)), String)
msg = "The following dependency could not be found : #{@source}"
super(msg)
end
end
class InvalidGitAuthToken < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :source
sig { params(source: String).void }
def initialize(source)
@source = T.let(sanitize_source(source), String)
msg = "Missing or invalid authentication token while accessing github package : #{@source}"
super(msg)
end
end
class RegistryError < DependabotError
extend T::Sig
sig { returns(Integer) }
attr_reader :status
sig { params(status: Integer, msg: String).void }
def initialize(status, msg)
@status = status
super(msg)
end
end
# Useful for JS file updaters, where the registry API sometimes returns
# different results to the actual update process
class InconsistentRegistryResponse < DependabotError; end
###########################
# Dependency level errors #
###########################
class UpdateNotPossible < DependabotError
extend T::Sig
sig { returns(T::Array[String]) }
attr_reader :dependencies
sig { params(dependencies: T::Array[String]).void }
def initialize(dependencies)
@dependencies = dependencies
msg = "The following dependencies could not be updated: #{@dependencies.join(', ')}"
super(msg)
end
end
class GitDependenciesNotReachable < DependabotError
extend T::Sig
sig { returns(T::Array[String]) }
attr_reader :dependency_urls
sig { params(dependency_urls: T.any(String, T::Array[String])).void }
def initialize(*dependency_urls)
@dependency_urls =
T.let(dependency_urls.flatten.map { |uri| filter_sensitive_data(uri) }, T::Array[String])
msg = "The following git URLs could not be retrieved: " \
"#{@dependency_urls.join(', ')}"
super(msg)
end
end
class GitDependencyReferenceNotFound < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :dependency
sig { params(dependency: String).void }
def initialize(dependency)
@dependency = dependency
msg = "The branch or reference specified for #{@dependency} could not " \
"be retrieved"
super(msg)
end
end
class PathDependenciesNotReachable < DependabotError
extend T::Sig
sig { returns(T::Array[String]) }
attr_reader :dependencies
sig { params(dependencies: T.any(String, T::Array[String])).void }
def initialize(*dependencies)
@dependencies = T.let(dependencies.flatten, T::Array[String])
msg = "The following path based dependencies could not be retrieved: " \
"#{@dependencies.join(', ')}"
super(msg)
end
end
class GoModulePathMismatch < DependabotError
extend T::Sig
sig { returns(String) }
attr_reader :go_mod
sig { returns(String) }
attr_reader :declared_path
sig { returns(String) }
attr_reader :discovered_path
sig { params(go_mod: String, declared_path: String, discovered_path: String).void }
def initialize(go_mod, declared_path, discovered_path)
@go_mod = go_mod
@declared_path = declared_path
@discovered_path = discovered_path
msg = "The module path '#{@declared_path}' found in #{@go_mod} doesn't " \
"match the actual path '#{@discovered_path}' in the dependency's " \
"go.mod"
super(msg)
end
end
# Raised by UpdateChecker if all candidate updates are ignored
class AllVersionsIgnored < DependabotError; end
# Raised by FileParser if processing may execute external code in the update context
class UnexpectedExternalCode < DependabotError; end
class IncompatibleCPU < TypedDependabotError
sig { params(message: T.any(T.nilable(String), MatchData)).void }
def initialize(message = nil)
super("incompatible_cpu", message)
end
end
class NetworkUnsafeHTTP < TypedDependabotError
sig { params(message: T.any(T.nilable(String), MatchData)).void }
def initialize(message = nil)
super("network_unsafe_http", message)
end
end
class SnapshotsUnavailableGraphError < TypedDependabotError
sig { params(message: T.any(T.nilable(String), MatchData)).void }
def initialize(message = nil)
super("snapshots_unavailable_graph_error", message)
end
end
end
# rubocop:enable Metrics/ModuleLength
|