Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
require: rubocop-performance

AllCops:
DisabledByDefault: true
Exclude:
- 'bundler/**/*'
- 'lib/rubygems/resolver/molinillo/**/*'
- 'pkg/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.3

Layout/AccessModifierIndentation:
Enabled: true

Layout/ArrayAlignment:
Enabled: true

Layout/BlockAlignment:
Enabled: true

Layout/CaseIndentation:
Enabled: true

Layout/ClosingParenthesisIndentation:
Enabled: true

Layout/CommentIndentation:
Enabled: true

Layout/ElseAlignment:
Enabled: true

Layout/EmptyLinesAroundAccessModifier:
Enabled: true

# Force Unix line endings.
Layout/EndOfLine:
Enabled: true
EnforcedStyle: lf

Layout/EmptyLines:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundMethodBody:
Enabled: true

Layout/ExtraSpacing:
Enabled: true

Layout/FirstHashElementIndentation:
Enabled: true
EnforcedStyle: consistent

Layout/FirstArrayElementIndentation:
Enabled: true
EnforcedStyle: consistent

Layout/IndentationConsistency:
Enabled: true

Layout/IndentationWidth:
Enabled: true

Layout/LeadingEmptyLines:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceInsideBlockBraces:
Enabled: true
SpaceBeforeBlockParameters: false

Layout/SpaceInsideParens:
Enabled: true

Layout/TrailingEmptyLines:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Lint/DuplicateMethods:
Enabled: true

Lint/ParenthesesAsGroupedExpression:
Enabled: true

Layout/EndAlignment:
Enabled: true

Naming/HeredocDelimiterCase:
Enabled: true

Naming/HeredocDelimiterNaming:
Enabled: true
ForbiddenDelimiters:
- ^RB$

Performance/StartWith:
Enabled: true

Performance/StringReplacement:
Enabled: true

Security/Open:
Enabled: true

Style/Encoding:
Enabled: true
Exclude:
- test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec

Style/EvalWithLocation:
Enabled: true

Style/IfInsideElse:
Enabled: false

Style/MethodCallWithoutArgsParentheses:
Enabled: true

Style/MethodDefParentheses:
Enabled: true

Style/MultilineIfThen:
Enabled: true

Style/MutableConstant:
Enabled: true

Style/NilComparison:
Enabled: true

Style/BlockDelimiters:
Enabled: true

Style/PercentLiteralDelimiters:
Enabled: true

# Having these make it easier to *not* forget to add one when adding a new
# value and you can simply copy the previous line.
Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: comma
11 changes: 8 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ gem "faraday_middleware", "~> 1.0.0"
gem "oa-openid", "~> 0.0.2"
gem "omniauth-openid", "~> 2.0.1"
gem "ruby-openid-apps-discovery", "~> 1.2.0"
gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
gem "json-jwt", "~> 1.13.0"
gem "json-jwt", "~> 1.13.0"

group :development do
gem "rubocop", "~> 0.80.1"
gem "rubocop-performance", "~> 1.5.2"
gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
end
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
aes_key_wrap (1.1.0)
ast (2.4.2)
attr_required (1.0.1)
bindata (2.4.8)
concurrent-ruby (1.1.8)
Expand Down Expand Up @@ -82,6 +83,7 @@ GEM
httpclient (2.8.3)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
json-jwt (1.13.0)
activesupport (>= 4.2)
aes_key_wrap
Expand Down Expand Up @@ -115,6 +117,9 @@ GEM
validate_email
validate_url
webfinger (>= 1.0.1)
parallel (1.21.0)
parser (3.0.2.0)
ast (~> 2.4.1)
pp (0.2.0)
prettyprint
prettyprint (0.1.0)
Expand All @@ -131,7 +136,9 @@ GEM
ruby-openid (>= 2.1.8)
rack-protection (2.1.0)
rack
rainbow (3.0.0)
rake (12.3.3)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand All @@ -145,16 +152,28 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rubocop (0.80.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
ruby-openid (2.9.2)
ruby-openid-apps-discovery (1.2.0)
ruby-openid (>= 2.1.7)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.4)
swd (1.2.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
httpclient (>= 2.4)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (1.6.1)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
Expand All @@ -179,6 +198,8 @@ DEPENDENCIES
pp (= 0.2.0)
rake (~> 12.0)
rspec (~> 3.0)
rubocop (~> 0.80.1)
rubocop-performance (~> 1.5.2)
ruby-openid-apps-discovery (~> 1.2.0)
ruby-sigstore!

Expand Down
6 changes: 3 additions & 3 deletions lib/rubygems/commands/sign_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def usage # :nodoc:
end

def execute
config = SigStoreConfig.new().config
priv_key, pub_key = Crypto.new().generate_keys
config = SigStoreConfig.new.config
priv_key, pub_key = Crypto.new.generate_keys
proof, access_token = OpenIDHandler.new(priv_key).get_token
cert_response = HttpClient.new().get_cert(access_token, proof, pub_key, config.fulcio_host)
cert_response = HttpClient.new.get_cert(access_token, proof, pub_key, config.fulcio_host)
puts cert_response
end
end
2 changes: 1 addition & 1 deletion lib/rubygems/commands/verify_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def initialize
def execute
puts "verify"
end
end
end
18 changes: 9 additions & 9 deletions lib/rubygems/sigstore/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
require 'config'

class SigStoreConfig
def initialize; end
def config
Config.setup do |config|
config.use_env = true
config.env_prefix = 'sigstore'
config.env_separator = '_'
end
def initialize; end
def config
Config.setup do |config|
config.use_env = true
config.env_prefix = 'sigstore'
config.env_separator = '_'
end
settings_file = Config.setting_files(
File.expand_path('../../../../', __FILE__),
'development' # TODO: Get this from gemspec
)
)
return Config.load_and_set_settings(settings_file)
end
end
end
29 changes: 14 additions & 15 deletions lib/rubygems/sigstore/crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
require 'base64'
require 'openssl'

class Crypto
def initialize; end

def generate_keys
key = OpenSSL::PKey::RSA.generate(2048)
pkey = key.public_key
return [key, pkey, Base64.encode64(pkey.to_der)]
end

def sign_proof(priv_key, email)
proof = priv_key.sign(OpenSSL::Digest::SHA256.new, email)
return Base64.encode64(proof)
end
class Crypto
def initialize; end

def generate_keys
key = OpenSSL::PKey::RSA.generate(2048)
pkey = key.public_key
return [key, pkey, Base64.encode64(pkey.to_der)]
end

def sign_proof(priv_key, email)
proof = priv_key.sign(OpenSSL::Digest::SHA256.new, email)
return Base64.encode64(proof)
end
end

# class Crypto
# class Crypto
# def initialize; end

# def generate_keys
Expand All @@ -45,4 +45,3 @@ def sign_proof(priv_key, email)
# return Base64.encode64(proof)
# end
# end

Loading