Skip to content

Commit f19a5a9

Browse files
committed
Ruby: Add tests for Gemfile modeling
1 parent 3c69ab1 commit f19a5a9

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source "https://rubygems.org"
2+
3+
gem "rails", "7.0.0"
4+
gem "json", "~> 2.6.0"
5+
gem "jwt"
6+
7+
gem "loofah", ">= 2"
8+
9+
gem "invalid-version", "abc"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
gemCalls
2+
| Gemfile:3:1:3:20 | call to gem | rails | 7.0.0 | 7.0.0 |
3+
| Gemfile:4:1:4:22 | call to gem | json | ~> 2.6.0 | 2.6.0 |
4+
| Gemfile:7:1:7:20 | call to gem | loofah | >= 2 | 2 |
5+
versionBefore
6+
| 2 | 2.6.0 |
7+
| 2 | 7.0.0 |
8+
| 2.6.0 | 7.0.0 |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import codeql.ruby.frameworks.Gemfile
2+
3+
query predicate gemCalls(
4+
Gemfile::Gem gem, string name, Gemfile::VersionConstraint constraint, string version
5+
) {
6+
name = gem.getName() and
7+
constraint = gem.getAVersionConstraint() and
8+
version = constraint.getVersion()
9+
}
10+
11+
query predicate versionBefore(string before, string after) {
12+
exists(Gemfile::VersionConstraint c1, Gemfile::VersionConstraint c2 |
13+
c1.getVersion() = before and c2.getVersion() = after
14+
|
15+
c1.getVersion().before(after)
16+
)
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gem "this-gem-not-in-gemfile", "1.2"

0 commit comments

Comments
 (0)