Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 5.x] Update rubygems signature varification to ensure all dependencies are pulled with correct versions #299

Merged
merged 1 commit into from
Aug 25, 2023
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
4 changes: 2 additions & 2 deletions tests/jenkins/TestPublishToRubyGems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestPublishToRubyGems extends BuildPipelineTest {
assertThat(curlCommands, hasItem(
"cd /tmp/workspace/dist && curl --fail --data-binary @`ls *.gem` -H 'Authorization:API_KEY' -H 'Content-Type: application/octet-stream' https://rubygems.org/api/v1/gems".toString()
))
assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version\n cd /tmp/workspace/dist && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n "))
assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version\n cd /tmp/workspace/dist && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n "))
}

@Test
Expand All @@ -40,7 +40,7 @@ class TestPublishToRubyGems extends BuildPipelineTest {
def gemCommands = getCommands('sh', 'gem')
assertThat(curlCommands, hasItem(
"cd /tmp/workspace/test && curl --fail --data-binary @`ls *.gem` -H 'Authorization:API_KEY' -H 'Content-Type: application/octet-stream' https://rubygems.org/api/v1/gems".toString()))
assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certificate/path\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version\n cd /tmp/workspace/test && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n "))
assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certificate/path\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version\n cd /tmp/workspace/test && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n "))
}

def getCommands(method, text) {
Expand Down
2 changes: 2 additions & 0 deletions tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
gem install $gemNameWithVersion
gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g')
gem uninstall $gemName
gem install $gemNameWithVersion -P MediumSecurity
gem uninstall $gemName
gem install $gemNameWithVersion -P HighSecurity
)
publishToRubyGems.string({credentialsId=ruby-api-key, variable=API_KEY})
Expand Down
2 changes: 2 additions & 0 deletions tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
gem install $gemNameWithVersion
gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g')
gem uninstall $gemName
gem install $gemNameWithVersion -P MediumSecurity
gem uninstall $gemName
gem install $gemNameWithVersion -P HighSecurity
)
publishToRubyGems.string({credentialsId=ruby-api-key, variable=API_KEY})
Expand Down
2 changes: 2 additions & 0 deletions vars/publishToRubyGems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void call(Map args = [:]) {
gem install \$gemNameWithVersion
gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')
gem uninstall \$gemName
gem install \$gemNameWithVersion -P MediumSecurity
gem uninstall \$gemName
gem install \$gemNameWithVersion -P HighSecurity
"""

Expand Down