Ruby: Add tests for Gemfile modeling

This commit is contained in:
Harry Maclean
2023-10-10 12:06:51 +01:00
parent 3c69ab10f2
commit f19a5a9837
4 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
source "https://rubygems.org"
gem "rails", "7.0.0"
gem "json", "~> 2.6.0"
gem "jwt"
gem "loofah", ">= 2"
gem "invalid-version", "abc"

View File

@@ -0,0 +1,8 @@
gemCalls
| Gemfile:3:1:3:20 | call to gem | rails | 7.0.0 | 7.0.0 |
| Gemfile:4:1:4:22 | call to gem | json | ~> 2.6.0 | 2.6.0 |
| Gemfile:7:1:7:20 | call to gem | loofah | >= 2 | 2 |
versionBefore
| 2 | 2.6.0 |
| 2 | 7.0.0 |
| 2.6.0 | 7.0.0 |

View File

@@ -0,0 +1,17 @@
import codeql.ruby.frameworks.Gemfile
query predicate gemCalls(
Gemfile::Gem gem, string name, Gemfile::VersionConstraint constraint, string version
) {
name = gem.getName() and
constraint = gem.getAVersionConstraint() and
version = constraint.getVersion()
}
query predicate versionBefore(string before, string after) {
exists(Gemfile::VersionConstraint c1, Gemfile::VersionConstraint c2 |
c1.getVersion() = before and c2.getVersion() = after
|
c1.getVersion().before(after)
)
}

View File

@@ -0,0 +1 @@
gem "this-gem-not-in-gemfile", "1.2"