Skip to content

Commit

Permalink
feat(adding_signature_validation): Adding Validation for signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
pryorda committed Mar 30, 2021
1 parent 3a91783 commit 72430d9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/python-package.yml
Expand Up @@ -20,6 +20,9 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -42,6 +45,14 @@ jobs:
- name: integration tests
run: |
pytest tests/integration
- name: Setup ruby env
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- run: |
gem install pre-commit-sign
export COMMIT_MESSAGE=$(git log -1)
ruby validate-signature.rb "${COMMIT_MESSAGE}"
deploy:
strategy:
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
@@ -1,4 +1,8 @@
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.6 # Use the sha / tag you want to point at
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
hooks:
Expand Down
19 changes: 19 additions & 0 deletions validate-signature.rb
@@ -0,0 +1,19 @@
#!/bin/ruby
require 'pre-commit-sign'
if ARGV.length >= 1
puts 'Validating signature'
commit_message = ARGV[0]
message_body = commit_message.split("\n").select { |l| l.start_with?(' ') }.join("\n").gsub(/^ /, '')
pcs = PrecommitSign.from_message(message_body)
pcs.date = DateTime.strptime(/^Date:\s+(.*)$/.match(commit_message).captures.first, '%a %b %d %T %Y %z').to_time
puts "Commit Message: #{message_body}"
if pcs.valid_signature?
puts 'Perfect'
else
puts 'Not valid'
exit 1
end
else
puts "Need a commit message to validate signature from. Try pre-commit install -f && pre-commit install --install-hooks -t commit-msg -f before commiting your code."
exit 1
end
1 change: 1 addition & 0 deletions vmware_exporter/defer.py
@@ -1,6 +1,7 @@
'''
Helpers for writing efficient twisted code, optimized for coroutine scheduling efficiency
'''
# autopep8'd

from twisted.internet import defer
from twisted.python import failure
Expand Down
2 changes: 1 addition & 1 deletion vmware_exporter/helpers.py
@@ -1,5 +1,5 @@
# autopep8'd
import os

from pyVmomi import vmodl


Expand Down
2 changes: 1 addition & 1 deletion vmware_exporter/vmware_exporter.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- python -*-
# -*- coding: utf-8 -*-
# autopep8'd
"""
Handles collection of metrics for vmware.
"""
Expand Down Expand Up @@ -795,7 +796,6 @@ def vm_inventory(self):

@defer.inlineCallbacks
def customAttributesLabelNames(self, metric_type):

"""
vm perf, vms, vmguestes and snapshots metrics share the same custom attributes
as they re related to virtual machine objects
Expand Down

0 comments on commit 72430d9

Please sign in to comment.