mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Ruby: Add tests for Gemfile modeling
This commit is contained in:
9
ruby/ql/test/library-tests/frameworks/gemfile/Gemfile
Normal file
9
ruby/ql/test/library-tests/frameworks/gemfile/Gemfile
Normal 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"
|
||||
@@ -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 |
|
||||
17
ruby/ql/test/library-tests/frameworks/gemfile/Gemfile.ql
Normal file
17
ruby/ql/test/library-tests/frameworks/gemfile/Gemfile.ql
Normal 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)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
gem "this-gem-not-in-gemfile", "1.2"
|
||||
Reference in New Issue
Block a user