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

Add the AI LLM Methodology #20

Merged
merged 10 commits into from
Jul 25, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['2.5', '2.6', '2.7']
ruby: ['3.1', '3.2', '3.3']
name: Test ruby v${{ matrix.ruby }} support
steps:
- uses: actions/checkout@v1
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
- uses: actions/checkout@v4
- name: Set up Ruby 3.1
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.x
ruby-version: '3.1.x'
- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
Expand Down
8 changes: 4 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.1
NewCops: enable

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Metrics/LineLength:
Layout/LineLength:
Max: 120
IgnoreCopDirectives: true

Metrics/BlockLength:
ExcludedMethods:
AllowedMethods:
- configure
- context
- define
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.2
3.3.0
28 changes: 22 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/)

## [Unreleased]
## [0.6.0] - 2024-07-23

### Added
- AI LLM Testing Methodology

## [0.5.2] - 2023-05-08

### Changed
- Title of API Methodology updated

## [0.5.1] - 2023-04-06

### Changes
- None; Version bump because we forgot to update the git submodule

## [0.5.0] - 2023-04-05

### Added
- API Testing Methodology included

## [0.4.0] - 2023-03-03

### Added
- support for methodologies v0.1
- Added new methodology for mobile_ios
- Added new methodology for mobile_android
- Added new methodology for binaries
- Added new methodology for network
- Added new methodology for Api Testing

### Changed

### Removed
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in bmt-ruby.gemspec
gemspec

group :development do
gem 'bundler', require: false
gem 'pry', require: false
gem 'rake', require: false
gem 'rspec', require: false
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
end
16 changes: 5 additions & 11 deletions bmt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@ Gem::Specification.new do |spec|
spec.name = 'bmt'
spec.version = Bmt::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ['Federico Tagliabue']
spec.email = ['[email protected]']
spec.date = Date.today.to_s
spec.authors = ['Federico Tagliabue', 'Andy White']
spec.email = ['[email protected]', '[email protected]']
spec.summary = 'Ruby wrapper for Bugcrowd\'s Methodology Taxonomy'
spec.homepage = 'https://github.com/bugcrowd/bmt-ruby'
spec.license = 'MIT'
spec.files = Dir['lib/**/*.{rb,json}']
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.5'

spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'pry', '~> 0.11'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rspec', '~> 3.6'
spec.add_development_dependency 'rubocop', '0.56.0'
spec.required_ruby_version = '>= 3.1'

spec.metadata = {
'homepage_uri' => 'https://github.com/bugcrowd/bmt-ruby',
'changelog_uri' => 'https://github.com/bugcrowd/bmt-ruby/blob/main/CHANGELOG.md',
'source_code_uri' => 'https://github.com/bugcrowd/bmt-ruby',
'bug_tracker_uri' => 'https://github.com/bugcrowd/bmt-ruby/issues'
'bug_tracker_uri' => 'https://github.com/bugcrowd/bmt-ruby/issues',
'rubygems_mfa_required' => 'true'
}
end
14 changes: 7 additions & 7 deletions lib/bmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class MethodologyNotFoundError < StandardError; end
# returns a Methodology object given a key and a version
def find(key, version: current_version)
raise VersionNotFoundError unless versions.include?(version)
raise MethodologyNotFoundError unless methodology_keys(version: version).include?(key)
raise MethodologyNotFoundError unless methodology_keys(version:).include?(key)

@methodologies[version].nil? && @methodologies[version] = {}

@methodologies[version][key] ||= Methodology.new(
key: key,
version: version,
attributes: methodology_json(key, version: version)
key:,
version:,
attributes: methodology_json(key, version:)
)

@methodologies[version][key]
Expand All @@ -43,7 +43,7 @@ def methodology_keys(version: current_version)
DATA_DIR.join(version, 'methodologies').entries
.map(&:basename)
.map(&:to_s)
.select { |dirname| dirname =~ /json/ }
.grep(/json/)
.map { |filepath| File.basename(filepath, File.extname(filepath)) }
end

Expand All @@ -55,7 +55,7 @@ def versions
end

def methodology_json(key, version: current_version)
JSON.parse(methodology_pathname(key, version: version).read)
JSON.parse(methodology_pathname(key, version:).read)
end

def methodology_pathname(key, version: current_version)
Expand All @@ -67,6 +67,6 @@ def json_dir_names
DATA_DIR.entries
.map(&:basename)
.map(&:to_s)
.select { |dirname| dirname =~ /^[0-9]+\.[0-9]/ }.sort
.grep(/^[0-9]+\.[0-9]/).sort
end
end
2 changes: 1 addition & 1 deletion lib/bmt/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bmt
VERSION = '0.5.2'.freeze
VERSION = '0.6.0'.freeze
end
2 changes: 1 addition & 1 deletion lib/data/0.1
Submodule 0.1 updated 1 files
+517 −0 methodologies/ai_llm.json
4 changes: 2 additions & 2 deletions spec/bmt/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
describe '#new' do
subject do
described_class.new(
step: step,
attributes: attributes
step:,
attributes:
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/bmt/methodology_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe '#new' do
subject do
described_class.new(key: methodology_key,
version: version,
version:,
attributes: methodology_json)
end

Expand All @@ -28,7 +28,7 @@
describe '#steps' do
subject do
described_class.new(key: methodology_key,
version: version,
version:,
attributes: methodology_json).steps
end

Expand Down
16 changes: 8 additions & 8 deletions spec/bmt/step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
describe '#new' do
subject do
described_class.new(
methodology: methodology,
attributes: attributes
methodology:,
attributes:
)
end

Expand All @@ -29,8 +29,8 @@
describe '#items' do
subject do
described_class.new(
methodology: methodology,
attributes: attributes
methodology:,
attributes:
).items
end

Expand All @@ -48,15 +48,15 @@
end

context 'with an executive_summary step type' do
let(:attributes) { methodology_json.dig('content', 'steps', 2) }

subject do
described_class.new(
methodology: methodology,
attributes: attributes
methodology:,
attributes:
)
end

let(:attributes) { methodology_json.dig('content', 'steps', 2) }

it 'returns the correct type' do
expect(subject.type).to eq 'executive_summary'
end
Expand Down
10 changes: 5 additions & 5 deletions spec/bmt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
subject { described_class.versions }

it 'return all of the versions in the filesystem in reverse semver order' do
is_expected.to eq(['2.1', '1.0'])
expect(subject).to eq(['2.1', '1.0'])
end
end

describe '#current_version' do
subject { described_class.current_version }

it 'return the most recent version number for the vrt' do
is_expected.to eq('2.1')
expect(subject).to eq('2.1')
end
end

Expand All @@ -22,15 +22,15 @@
subject { described_class.methodology_keys }

it 'returns methodologies for the latest version' do
is_expected.to match_array(['website-testing', 'outback-animal-testing'])
expect(subject).to match_array(%w[website-testing outback-animal-testing])
end
end

context 'with custom version' do
subject { described_class.methodology_keys(version: '1.0') }

it 'returns methodologies for the specified version' do
is_expected.to match_array(['website-testing'])
expect(subject).to match_array(['website-testing'])
end
end
end
Expand All @@ -51,7 +51,7 @@
end

context 'specifing version' do
subject(:methodology) { described_class.find(key, version: version) }
subject(:methodology) { described_class.find(key, version:) }

let(:key) { 'website-testing' }

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
c.syntax = :expect
end

config.before(:each) do
config.before do
# The following adds a new, test-only BMT versions
stub_const('BMT::DATA_DIR', Pathname.new('spec/sample'))
end
Expand Down