Skip to content

Commit 3655e78

Browse files
authored
Ruby dependency license scanning support via Gemfile.lock. (#205)
* Ruby dependency license scanning support via Gemfile.lock. - Implements apache/skywalking#7744 - Library projects (with a *.gemspec in the same directory as Gemfile.lock) ignore development dependencies and include runtime dependencies and their transitives. - App projects (no *.gemspec) include both runtime and development dependencies from Gemfile.lock. - Will only work if Gemfile.lock is committed to version control, but this is the official recommendation of RubyGems: - https://bundler.io/guides/faq.html#using-gemfiles-inside-gems - License resolution honors user overrides/exclusions and may query the RubyGems API when necessary, with proper support for handling of various status codes. - Documentation updated (README.md) - Ruby setup and GitHub Actions example are in <details> tag to reduce noise
1 parent 07a607f commit 3655e78

File tree

8 files changed

+635
-0
lines changed

8 files changed

+635
-0
lines changed

.licenserc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ header: # `header` section is configurations for source codes license header.
7676
- "**/assets/assets.gen.go"
7777
- "docs/**.svg"
7878
- "pkg/gitignore/dir.go"
79+
- "pkg/deps/testdata/ruby/app/Gemfile.lock"
80+
- "pkg/deps/testdata/ruby/library/Gemfile.lock"
7981

8082
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
8183

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependency:
3838
- Cargo.toml # If this is a rust project.
3939
- package.json # If this is a npm project.
4040
- go.mod # If this is a Go project.
41+
- Gemfile.lock # If this is a Ruby project (Bundler). Ensure Gemfile.lock is committed.
4142
```
4243
4344
#### Check License Headers
@@ -102,6 +103,40 @@ To check dependencies license in GitHub Actions, add a step in your GitHub workf
102103
# flags: # optional: Extra flags appended to the command, for example, `--summary=path/to/template.tmpl`
103104
```
104105

106+
<details>
107+
<summary>Ruby projects (Bundler)</summary>
108+
109+
License-Eye can resolve Ruby dependencies and their licenses directly from Gemfile.lock.
110+
111+
Rules applied:
112+
- If a .gemspec file exists in the same directory as Gemfile.lock, the project is treated as a library and development dependencies are ignored. Runtime dependencies (and their transitives) are included.
113+
- If no .gemspec is present, the project is treated as an app and all dependencies from Gemfile.lock are considered (both runtime and development).
114+
115+
Requirements:
116+
- Commit Gemfile.lock to version control so License-Eye can read the locked dependency graph.
117+
- For libraries, ensure the .gemspec is present in the same directory as Gemfile.lock.
118+
119+
Minimal config snippet:
120+
121+
```yaml
122+
dependency:
123+
files:
124+
- Gemfile.lock
125+
```
126+
127+
GitHub Actions example:
128+
129+
```yaml
130+
- name: Check Ruby dependencies' licenses
131+
uses: apache/skywalking-eyes/dependency@main
132+
with:
133+
config: .licenserc.yaml
134+
```
135+
136+
Note: License-Eye may query the RubyGems API to determine licenses when they are not specified in your configuration. Ensure the workflow has network access.
137+
138+
</details>
139+
105140
### Docker Image
106141
107142
For Bash, users can execute the following command,

pkg/deps/resolve.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var Resolvers = []Resolver{
3232
new(MavenPomResolver),
3333
new(JarResolver),
3434
new(CargoTomlResolver),
35+
new(GemfileLockResolver),
3536
}
3637

3738
func Resolve(config *ConfigDeps, report *Report) error {

0 commit comments

Comments
 (0)