From b545cf5dc7ba3304b1206b315ab421e84256815c Mon Sep 17 00:00:00 2001 From: Jayme Deffenbaugh Date: Fri, 12 Jan 2024 22:48:10 -0500 Subject: [PATCH] Include an arm64 shared library in the ruby gem (#1733) * Update nokogiri to version with support for apple silicon * Update gem dependencies to address spec failures running with Ruby 3 * Require ActiveRecordAdapter from spec that uses it * Add support for both x86_64 and arm64 linux architectures * Build both x86 and arm dynamic libraries for ruby * Use Ruby 2.6 as minimum tested version and 3.2 for all ruby-related tasks Rationale: 2.6.10 is what ships with macOS 14.0 even though support for it stopped in March of 2022 and 3.2 is the latest stable version. * Ensure the ruby libs are copied and available for testing * Bump solargraph and rubocop Disable new cops for existing violations * Update bundler to get rid of SPELL_CHECKERS warning * Do not suggest extensions * Simplify YARD docs for query method Add the host and bindings parameters so calls that contain them don't fail typecheck * Must use Ruby 2.4 in order to build the docs on main * Must use Ruby 2.4 in order to build the docs on main * Use .ruby-version instead of hard-coding the current ruby version in Github actions The rationale for this is from the way that docs diffing works. Both the base branch and the new branch need to be able to build using the version of Ruby supported by that branch. Without this change, when a PR is introduced that updates the target Ruby version, a followup PR will be required to update the github action for building the 'base' branch's version of the docs. With this change, github actions will choose the version of Ruby targeted by the branch it is trying to build * Clippy * Cargo fmt * Test * Try building aarch64 first Seeing if [this](https://github.com/cross-rs/cross/issues/724#issuecomment-1638593579) is a quick fix so I can avoid any deeper debugging. * Keep shuffling the deck chairs * Revert "Test" This reverts commit 7feebd1044adb366c1467d3afe514902195a34d3. * Add 0.27.3 changelog * Bump version * Let's just release now instead --------- Co-authored-by: Gabe Jackson <17556281+gj@users.noreply.github.com> --- .github/workflows/docs-diff.yml | 7 +- .github/workflows/docs-preview.yml | 3 +- .github/workflows/publish-docs.yml | 3 +- .github/workflows/publish.yml | 2 +- .github/workflows/release.yml | 41 +++-- .github/workflows/test.yml | 6 +- .gitignore | 1 - Cargo.lock | 12 +- Makefile | 5 +- VERSION | 2 +- .../any/project/changelogs/2024-01-12.md | 21 +++ docs/examples/Makefile | 2 +- languages/java/oso/pom.xml | 2 +- languages/js/package.json | 2 +- languages/python/docs/conf.py | 4 +- languages/python/oso/oso/oso.py | 2 +- languages/ruby/.gitignore | 1 + languages/ruby/.rubocop.yml | 42 +++++- languages/ruby/.ruby-version | 1 + languages/ruby/Gemfile.lock | 142 ++++++++++-------- languages/ruby/Makefile | 22 ++- languages/ruby/lib/oso/polar/ffi.rb | 17 ++- languages/ruby/lib/oso/polar/polar.rb | 13 +- languages/ruby/lib/oso/version.rb | 2 +- languages/ruby/oso-oso.gemspec | 8 +- .../oso/polar/data_filtering/gitclub_spec.rb | 1 + languages/rust/oso-derive/Cargo.toml | 2 +- languages/rust/oso/Cargo.toml | 8 +- languages/rust/oso/tests/test_polar.rs | 4 +- polar-c-api/Cargo.toml | 4 +- polar-core/Cargo.toml | 2 +- polar-language-server/Cargo.toml | 4 +- polar-language-server/src/lib.rs | 16 +- polar-wasm-api/Cargo.toml | 4 +- vscode/oso/package.json | 2 +- 35 files changed, 262 insertions(+), 148 deletions(-) create mode 100644 docs/content/any/project/changelogs/2024-01-12.md create mode 100644 languages/ruby/.ruby-version diff --git a/.github/workflows/docs-diff.yml b/.github/workflows/docs-diff.yml index ca5f3224a1..8b51e50726 100644 --- a/.github/workflows/docs-diff.yml +++ b/.github/workflows/docs-diff.yml @@ -49,7 +49,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" if: steps.cache.outputs.cache-hit != 'true' - name: Install yard @@ -84,7 +83,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: '0.79.1' + hugo-version: "0.79.1" if: steps.cache.outputs.cache-hit != 'true' - name: Build Hugo docs env: @@ -136,7 +135,7 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' + ruby-version: "2.7" working-directory: "languages/ruby" if: steps.cache.outputs.cache-hit != 'true' - name: Install yard @@ -171,7 +170,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: '0.79.1' + hugo-version: "0.79.1" if: steps.cache.outputs.cache-hit != 'true' - name: Build Hugo docs env: diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index 43683c90e1..d38a0a517d 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -31,7 +31,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" - name: Install yard run: gem install yard @@ -61,7 +60,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: '0.79.1' + hugo-version: "0.79.1" - name: Get branch name (branch) if: github.event_name != 'pull_request' shell: bash diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 627e37eb68..55191c3e24 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -6,7 +6,7 @@ on: description: "docs s3 path (docs.oso.dev or docs-preview.oso.dev)" oso_version: description: "oso release to build docs for" - default: "0.27.2" # oso_version + default: "0.27.3" # oso_version flask_oso_version: description: "flask oso release to build docs for" default: "0.27.1" # flask_oso_version @@ -49,7 +49,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" - name: Install yard run: gem install yard diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 70a096d6f0..469d479309 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -108,7 +108,7 @@ jobs: - name: Set up ruby ${{ matrix.ruby-version }} uses: ruby/setup-ruby@v1 with: - ruby-version: "2.7" + ruby-version: "3.2" working-directory: "languages/ruby" - run: gem push oso-oso-${{ github.event.inputs.version }}.gem working-directory: "oso-ruby-${{ github.event.inputs.version }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 121c3abc74..7aef37a53d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,31 +55,42 @@ jobs: profile: minimal toolchain: 1.69.0 override: true - - name: Build release libraries - run: cargo build --release -p polar-c-api - - name: Build x86_64 release musl library - run: | - rustup target add x86_64-unknown-linux-musl - RUSTFLAGS="-C target-feature=-crt-static" cargo build --target x86_64-unknown-linux-musl --release -p polar-c-api - - name: Download cross + - name: Install cross env: GH_TOKEN: ${{ github.token }} - run: gh release download --repo cross-rs/cross --pattern 'cross-x86_64-unknown-linux-gnu\.tar\.gz' + run: | + gh release download --repo cross-rs/cross --pattern 'cross-x86_64-unknown-linux-gnu\.tar\.gz' + tar -xzvf cross-x86_64-unknown-linux-gnu.tar.gz + - name: Build aarch64 dynamic lib + run: | + rustup target add aarch64-unknown-linux-gnu + RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-gnu --release -p polar-c-api - name: Build aarch64 release musl library run: | rustup target add aarch64-unknown-linux-musl - tar -xzvf cross-x86_64-unknown-linux-gnu.tar.gz RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-musl --release -p polar-c-api + - name: Build x86_64 release libraries + run: cargo build --release -p polar-c-api + - name: Build x86_64 release musl library + run: | + rustup target add x86_64-unknown-linux-musl + RUSTFLAGS="-C target-feature=-crt-static" cargo build --target x86_64-unknown-linux-musl --release -p polar-c-api - name: Rename static lib run: mv target/release/libpolar.a target/libpolar-${{runner.os}}.a - name: Rename x86_64 static lib run: mv target/x86_64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-x86_64.a - name: Rename aarch64 static lib run: mv target/aarch64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-aarch64.a + - name: Rename x86_64 dynamic lib + run: mv target/release/libpolar.so target/libpolar-x86_64.so + - name: Rename aarch64 dynamic lib + run: mv target/aarch64-unknown-linux-gnu/release/libpolar.so target/libpolar-aarch64.so - uses: actions/upload-artifact@v2 with: name: oso_library - path: target/release/libpolar.so + path: | + target/libpolar-x86_64.so + target/libpolar-aarch64.so - uses: actions/upload-artifact@v2 with: name: oso_library @@ -252,7 +263,7 @@ jobs: - name: Copy libraries into resources. run: | mkdir -p languages/java/oso/src/main/resources/linux - cp -r oso_library/libpolar.so languages/java/oso/src/main/resources/linux/ + cp -r oso_library/libpolar-x86_64.so languages/java/oso/src/main/resources/linux/libpolar.so mkdir -p languages/java/oso/src/main/resources/macos cp -r oso_library/libpolar-macOS-fat.dylib languages/java/oso/src/main/resources/macos/libpolar.dylib mkdir -p languages/java/oso/src/main/resources/win @@ -280,7 +291,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" - name: Set version env id: version @@ -292,7 +302,8 @@ jobs: - name: Copy libraries into resources. run: | mkdir -p languages/ruby/ext/oso-oso/lib - cp -r oso_library/libpolar.so languages/ruby/ext/oso-oso/lib/ + cp -r oso_library/libpolar-x86_64.so languages/ruby/ext/oso-oso/lib/ + cp -r oso_library/libpolar-aarch64.so languages/ruby/ext/oso-oso/lib/ cp -r oso_library/libpolar-macOS-fat.dylib languages/ruby/ext/oso-oso/lib/libpolar.dylib cp -r oso_library/polar.dll languages/ruby/ext/oso-oso/lib/ - name: Test @@ -689,7 +700,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-11, windows-2019] - ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2'] + ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"] steps: - uses: actions/checkout@v2 - name: Set version env @@ -805,7 +816,7 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' + ruby-version: "2.7" working-directory: "docs/examples/quickstart/ruby" - name: Use Node.js 12 uses: actions/setup-node@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be9adf3f10..6c0b9482a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,7 +57,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" - name: Lint Ruby code working-directory: "languages/ruby" @@ -214,7 +213,6 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '2.7' working-directory: "languages/ruby" - name: Test ruby run: make ruby-test @@ -350,8 +348,8 @@ jobs: - name: Install Ruby + gems uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' bundler-cache: true + working-directory: "languages/ruby" - name: Use Node.js 18 uses: actions/setup-node@v3 with: @@ -362,6 +360,8 @@ jobs: java-version: "11" - name: Build python lib run: make python-build + - name: Build ruby lib + run: make ruby-build - name: Python test deps run: make -C languages/python/oso test-requirements - name: Build js lib diff --git a/.gitignore b/.gitignore index 7246a61d40..06f06a361b 100644 --- a/.gitignore +++ b/.gitignore @@ -174,7 +174,6 @@ cython_debug/ # Java class files *.class -.ruby-version languages/java/oso/dependency-reduced-pom.xml languages/java/oso/src/main/resources/* diff --git a/Cargo.lock b/Cargo.lock index 7f1588d57b..f2c82bef56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,7 @@ checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" [[package]] name = "oso" -version = "0.27.2" +version = "0.27.3" dependencies = [ "anyhow", "clap 3.2.23", @@ -753,7 +753,7 @@ dependencies = [ [[package]] name = "oso-derive" -version = "0.27.2" +version = "0.27.3" dependencies = [ "quote", "syn", @@ -867,7 +867,7 @@ dependencies = [ [[package]] name = "polar-c-api" -version = "0.27.2" +version = "0.27.3" dependencies = [ "cbindgen", "polar-core", @@ -877,7 +877,7 @@ dependencies = [ [[package]] name = "polar-core" -version = "0.27.2" +version = "0.27.3" dependencies = [ "criterion", "indoc", @@ -897,7 +897,7 @@ dependencies = [ [[package]] name = "polar-language-server" -version = "0.27.2" +version = "0.27.3" dependencies = [ "console_error_panic_hook", "js-sys", @@ -911,7 +911,7 @@ dependencies = [ [[package]] name = "polar-wasm-api" -version = "0.27.2" +version = "0.27.3" dependencies = [ "console_error_panic_hook", "js-sys", diff --git a/Makefile b/Makefile index 446f9b270b..739d0f78bb 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,9 @@ python-django-test: python-build python-django-build python-sqlalchemy-test: python-build $(MAKE) -C languages/python/sqlalchemy-oso test +ruby-build: rust-build + $(MAKE) -C languages/ruby copy_lib + ruby-test: $(MAKE) -C languages/ruby test @@ -55,7 +58,7 @@ java-test: go-test: rust-build $(MAKE) -C languages/go test -docs-test: python-build +docs-test: python-build ruby-build $(MAKE) -C docs test fmt: fmt-java fmt-rust fmt-python fmt-js fmt-go diff --git a/VERSION b/VERSION index 3edc695dce..b38e1e76f5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.2 +0.27.3 diff --git a/docs/content/any/project/changelogs/2024-01-12.md b/docs/content/any/project/changelogs/2024-01-12.md new file mode 100644 index 0000000000..382204bdb1 --- /dev/null +++ b/docs/content/any/project/changelogs/2024-01-12.md @@ -0,0 +1,21 @@ +--- +title: Release 2024-01-12 +menuTitle: 2024-01-12 +any: true +description: >- + Changelog for Release 2024-01-12 (0.27.3) containing new features, + bug fixes, and more. +--- + +## `oso` 0.27.3 + +### Ruby + +#### New features + +##### Linux AArch64 support + +You can now run the `oso-oso` gem in AArch64 Linux environments, including in +Docker on Apple silicon. + +Thanks to [`@jdeff`](https://github.com/jdeff) for the contribution! diff --git a/docs/examples/Makefile b/docs/examples/Makefile index 2dea3466b4..dfe2f8eef6 100644 --- a/docs/examples/Makefile +++ b/docs/examples/Makefile @@ -7,7 +7,7 @@ JS_DIR := $(OSO_ROOT)/languages/js RUBY_DIR := $(OSO_ROOT)/languages/ruby # Needed for tests -JAVA_PACKAGE_JAR_PATH := $(JAVA_DIR)/oso/target/oso-0.27.2.jar +JAVA_PACKAGE_JAR_PATH := $(JAVA_DIR)/oso/target/oso-0.27.3.jar # Note: if you are using bundler in a sub-makefile (in a docs test for example), # you need to add `unexport BUNDLE_GEMFILE` to that makefile. Otherwise this diff --git a/languages/java/oso/pom.xml b/languages/java/oso/pom.xml index e6a02d53fb..3a34f9173f 100644 --- a/languages/java/oso/pom.xml +++ b/languages/java/oso/pom.xml @@ -12,7 +12,7 @@ com.osohq oso - 0.27.2 + 0.27.3 diff --git a/languages/js/package.json b/languages/js/package.json index d0a8ca755e..10a6dec7e2 100644 --- a/languages/js/package.json +++ b/languages/js/package.json @@ -1,6 +1,6 @@ { "name": "oso", - "version": "0.27.2", + "version": "0.27.3", "description": "oso authorization library.", "bin": "bin/repl.js", "main": "dist/src/index.js", diff --git a/languages/python/docs/conf.py b/languages/python/docs/conf.py index fd23f3f3c2..aaf97a0610 100644 --- a/languages/python/docs/conf.py +++ b/languages/python/docs/conf.py @@ -42,8 +42,8 @@ project = "oso" copyright = "2020-2021 Oso Security, Inc" author = "oso" -version = "0.27.2" -release = "0.27.2" +version = "0.27.3" +release = "0.27.3" # -- General configuration --------------------------------------------------- diff --git a/languages/python/oso/oso/oso.py b/languages/python/oso/oso/oso.py index e60bba17ac..8f6edc458b 100644 --- a/languages/python/oso/oso/oso.py +++ b/languages/python/oso/oso/oso.py @@ -1,6 +1,6 @@ """Core oso functionality""" -__version__ = "0.27.2" +__version__ = "0.27.3" import os from typing import Any, List, Set, Type diff --git a/languages/ruby/.gitignore b/languages/ruby/.gitignore index ae0efc3a99..7bc09d589e 100644 --- a/languages/ruby/.gitignore +++ b/languages/ruby/.gitignore @@ -11,3 +11,4 @@ vendor # rspec failure tracking .rspec_status +ext diff --git a/languages/ruby/.rubocop.yml b/languages/ruby/.rubocop.yml index c58f59b6f2..8ee21a6b58 100644 --- a/languages/ruby/.rubocop.yml +++ b/languages/ruby/.rubocop.yml @@ -1,10 +1,50 @@ AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.6 Exclude: - "**/*~" - "bin/oso" - "vendor/**/*" NewCops: enable + SuggestExtensions: false + Naming/FileName: Exclude: - "lib/oso-oso.rb" + +Layout/EmptyLineBetweenDefs: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false + +Gemspec/RequireMFA: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false + +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/SymbolConversion: + Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false + +Style/FetchEnvVar: + Enabled: false +Style/RedundantCurrentDirectoryInPath: + Enabled: false +Style/QuotedSymbols: + Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/CommentAnnotation: + Enabled: false +Style/FileRead: + Enabled: false +Style/HashConversion: + Enabled: false diff --git a/languages/ruby/.ruby-version b/languages/ruby/.ruby-version new file mode 100644 index 0000000000..be94e6f53d --- /dev/null +++ b/languages/ruby/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/languages/ruby/Gemfile.lock b/languages/ruby/Gemfile.lock index 0456899e06..17278f2993 100644 --- a/languages/ruby/Gemfile.lock +++ b/languages/ruby/Gemfile.lock @@ -1,43 +1,55 @@ PATH remote: . specs: - oso-oso (0.27.2) + oso-oso (0.27.3) ffi (~> 1.0) GEM remote: https://rubygems.org/ specs: - activemodel (5.2.6) - activesupport (= 5.2.6) - activerecord (5.2.6) - activemodel (= 5.2.6) - activesupport (= 5.2.6) - arel (>= 9.0) - activesupport (5.2.6) + activemodel (7.1.2) + activesupport (= 7.1.2) + activerecord (7.1.2) + activemodel (= 7.1.2) + activesupport (= 7.1.2) + timeout (>= 0.4.0) + activesupport (7.1.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (9.0.0) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) ast (2.4.2) backport (1.2.0) + base64 (0.2.0) benchmark (0.3.0) + bigdecimal (3.1.4) byebug (11.1.3) coderay (1.1.3) - concurrent-ruby (1.1.9) - diff-lcs (1.4.4) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) + diff-lcs (1.5.0) + drb (2.2.0) + ruby2_keywords e2mmap (0.1.0) - ffi (1.15.4) - i18n (1.8.11) + ffi (1.16.3) + i18n (1.14.1) concurrent-ruby (~> 1.0) jaro_winkler (1.5.6) + json (2.7.1) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) + language_server-protocol (3.17.0.3) method_source (1.0.0) mini_portile2 (2.8.5) - minitest (5.14.4) + minitest (5.20.0) + mutex_m (0.2.0) nokogiri (1.15.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -45,68 +57,78 @@ GEM racc (~> 1.4) nokogiri (1.15.5-x86_64-linux) racc (~> 1.4) - parallel (1.20.1) - parser (2.7.2.0) + parallel (1.23.0) + parser (3.2.2.4) ast (~> 2.4.1) - pry (0.13.1) + racc + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.9.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.13.0) + pry (>= 0.13, < 0.15) racc (1.7.3) - rainbow (3.0.0) + rainbow (3.1.1) rake (12.3.3) - regexp_parser (2.1.1) + rbs (2.8.4) + regexp_parser (2.8.3) reverse_markdown (2.1.1) nokogiri - rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rexml (3.2.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.3) - rubocop (0.89.1) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rubocop (1.58.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.3.0, < 1.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.8.0) - parser (>= 2.7.1.5) - ruby-progressbar (1.11.0) - solargraph (0.40.1) - backport (~> 1.1) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) + solargraph (0.49.0) + backport (~> 1.2) benchmark - bundler (>= 1.17.2) + bundler (~> 2.0) + diff-lcs (~> 1.4) e2mmap jaro_winkler (~> 1.5) kramdown (~> 2.3) kramdown-parser-gfm (~> 1.1) - parser (~> 2.3) - reverse_markdown (>= 1.0.5, < 3) - rubocop (>= 0.52) + parser (~> 3.0) + rbs (~> 2.0) + reverse_markdown (~> 2.0) + rubocop (~> 1.38) thor (~> 1.0) tilt (~> 2.0) yard (~> 0.9, >= 0.9.24) - sqlite3 (1.4.2) + sqlite3 (1.6.9) + mini_portile2 (~> 2.8.0) + sqlite3 (1.6.9-x86_64-darwin) + sqlite3 (1.6.9-x86_64-linux) thor (1.3.0) - thread_safe (0.3.6) tilt (2.3.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) - unicode-display_width (1.8.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) yard (0.9.34) PLATFORMS @@ -117,13 +139,13 @@ PLATFORMS DEPENDENCIES activerecord oso-oso! - pry-byebug (~> 3.9.0) + pry-byebug (~> 3.10.1) rake (~> 12.0) rspec (~> 3.0) - rubocop (~> 0.89.1) - solargraph (~> 0.40.0) + rubocop (~> 1.58.0) + solargraph (~> 0.49.0) sqlite3 yard (~> 0.9.25) BUNDLED WITH - 2.2.4 + 2.4.22 diff --git a/languages/ruby/Makefile b/languages/ruby/Makefile index d2e36f7eb9..79c5889d8e 100644 --- a/languages/ruby/Makefile +++ b/languages/ruby/Makefile @@ -1,12 +1,28 @@ -.PHONY: rust install test lint typecheck repl +.PHONY: rust copy_lib install test lint typecheck repl + +UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) rust: $(MAKE) -C ../.. rust-build +copy_lib: + mkdir -p ext/oso-oso/lib/ +ifeq ($(UNAME_S),Linux) +ifeq ($(UNAME_M),x86_64) + cp ../../target/debug/libpolar.so ext/oso-oso/lib/libpolar-x86_64.so +else + cp ../../target/debug/libpolar.so ext/oso-oso/lib/libpolar-aarch64.so +endif +endif +ifeq ($(UNAME_S),Darwin) + cp ../../target/debug/libpolar.dylib ext/oso-oso/lib/ +endif + install: bundle install -test: install rust +test: install rust copy_lib POLAR_IGNORE_NO_ALLOW_WARNING=1 bundle exec rake spec lint: install @@ -15,5 +31,5 @@ lint: install typecheck: install bundle exec solargraph typecheck -repl: install rust +repl: install rust copy_lib bundle exec oso diff --git a/languages/ruby/lib/oso/polar/ffi.rb b/languages/ruby/lib/oso/polar/ffi.rb index e4a52d4a46..23e0abd07d 100644 --- a/languages/ruby/lib/oso/polar/ffi.rb +++ b/languages/ruby/lib/oso/polar/ffi.rb @@ -6,12 +6,17 @@ module Oso module Polar # FFI classes shared between all ffi/*.rb modules module FFI - LIB = "#{::FFI::Platform::LIBPREFIX}polar.#{::FFI::Platform::LIBSUFFIX}" - RELEASE_PATH = File.expand_path(File.join(__dir__, "../../../ext/oso-oso/lib/#{LIB}")) - DEV_PATH = File.expand_path(File.join(__dir__, "../../../../../target/debug/#{LIB}")) - # If the lib exists in the ext/ dir, use it. Otherwise, fall back to - # checking the local Rust target dir. - LIB_PATH = File.file?(RELEASE_PATH) ? RELEASE_PATH : DEV_PATH + LIB = + case ::FFI::Platform::OS + when /darwin/ + 'libpolar.dylib' + when /windows|cygwin|msys/ + 'polar.dll' + else + "libpolar-#{::FFI::Platform::ARCH}.so" + end + + LIB_PATH = File.expand_path(File.join(__dir__, "../../../ext/oso-oso/lib/#{LIB}")) # Wrapper classes defined upfront to fix Ruby loading issues. Actual # implementations live in the sibling `ffi/` directory and are `require`d diff --git a/languages/ruby/lib/oso/polar/polar.rb b/languages/ruby/lib/oso/polar/polar.rb index 5aa87095b3..0006286d28 100644 --- a/languages/ruby/lib/oso/polar/polar.rb +++ b/languages/ruby/lib/oso/polar/polar.rb @@ -153,14 +153,11 @@ def load_str(str, filename: nil) # Query for a Polar predicate or string. # - # @overload query(query) - # @param query [String] - # @return [Enumerator] of resulting bindings - # @raise [Error] if the FFI call raises one. - # @overload query(query) - # @param query [Predicate] - # @return [Enumerator] of resulting bindings - # @raise [Error] if the FFI call raises one. + # @param query [String, Predicate] + # @param host [Host] + # @param bindings [Hash] + # @return [Enumerator] of resulting bindings + # @raise [Error] if the FFI call raises one. def query(query, host: self.host.dup, bindings: {}) case query when String diff --git a/languages/ruby/lib/oso/version.rb b/languages/ruby/lib/oso/version.rb index 64d83b0477..4ac63e09aa 100644 --- a/languages/ruby/lib/oso/version.rb +++ b/languages/ruby/lib/oso/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Oso - VERSION = '0.27.2' + VERSION = '0.27.3' end diff --git a/languages/ruby/oso-oso.gemspec b/languages/ruby/oso-oso.gemspec index e532ad702d..22c2979696 100644 --- a/languages/ruby/oso-oso.gemspec +++ b/languages/ruby/oso-oso.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| 'fixes. More context: [here](https://www.osohq.com/docs/oss/getting-started/deprecation.html).' spec.homepage = 'https://www.osohq.com/' - spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0') + spec.required_ruby_version = Gem::Requirement.new('>= 2.6.10') spec.metadata['homepage_uri'] = spec.homepage spec.metadata['source_code_uri'] = 'https://github.com/osohq/oso' @@ -37,11 +37,11 @@ Gem::Specification.new do |spec| # Development dependencies spec.add_development_dependency 'activerecord' - spec.add_development_dependency 'pry-byebug', '~> 3.9.0' + spec.add_development_dependency 'pry-byebug', '~> 3.10.1' spec.add_development_dependency 'rake', '~> 12.0' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_development_dependency 'rubocop', '~> 0.89.1' - spec.add_development_dependency 'solargraph', '~> 0.40.0' + spec.add_development_dependency 'rubocop', '~> 1.58.0' + spec.add_development_dependency 'solargraph', '~> 0.49.0' spec.add_development_dependency 'sqlite3' spec.add_development_dependency 'yard', '~> 0.9.25' end diff --git a/languages/ruby/spec/oso/polar/data_filtering/gitclub_spec.rb b/languages/ruby/spec/oso/polar/data_filtering/gitclub_spec.rb index a9577dfd68..d77376bdd1 100644 --- a/languages/ruby/spec/oso/polar/data_filtering/gitclub_spec.rb +++ b/languages/ruby/spec/oso/polar/data_filtering/gitclub_spec.rb @@ -3,6 +3,7 @@ require_relative './helpers' require 'sqlite3' require 'active_record' +require 'oso/polar/data/adapter/active_record_adapter' DB_FILE = 'gitclub_test.db' RSpec.describe Oso::Oso do # rubocop:disable Metrics/BlockLength diff --git a/languages/rust/oso-derive/Cargo.toml b/languages/rust/oso-derive/Cargo.toml index 381028ec52..047f43d59f 100644 --- a/languages/rust/oso-derive/Cargo.toml +++ b/languages/rust/oso-derive/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/osohq/oso" homepage = "https://www.osohq.com/" readme = "README.md" -version = "0.27.2" +version = "0.27.3" edition = "2021" diff --git a/languages/rust/oso/Cargo.toml b/languages/rust/oso/Cargo.toml index d06f31c2e1..be7b4a5352 100644 --- a/languages/rust/oso/Cargo.toml +++ b/languages/rust/oso/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" name = "oso" readme = "README.md" -version = "0.27.2" +version = "0.27.3" edition = "2021" @@ -31,8 +31,8 @@ required-features = ["anyhow"] [dependencies] impl-trait-for-tuples = "0.2.1" maplit = "1.0.2" -oso-derive = { path = "../oso-derive", version = "=0.27.2", optional = true } -polar-core = { path = "../../../polar-core", version = "=0.27.2" } +oso-derive = { path = "../oso-derive", version = "=0.27.3", optional = true } +polar-core = { path = "../../../polar-core", version = "=0.27.3" } thiserror = "1.0.30" tracing = { version = "0.1.29", features = ["log"] } @@ -52,7 +52,7 @@ uuid-10 = { package = "uuid", version = ">=1.0.0, <2.0.0", optional = true } [dev-dependencies] anyhow = "1.0.44" criterion = { version = "0.3.5", default-features = false } -oso-derive = { path = "../oso-derive", version = "=0.27.2" } +oso-derive = { path = "../oso-derive", version = "=0.27.3" } static_assertions = "1.1.0" tempfile = "3.2.0" tracing-subscriber = { version = "0.3.1", default-features = false, features = [ diff --git a/languages/rust/oso/tests/test_polar.rs b/languages/rust/oso/tests/test_polar.rs index 598820bc00..da367df9cc 100644 --- a/languages/rust/oso/tests/test_polar.rs +++ b/languages/rust/oso/tests/test_polar.rs @@ -119,7 +119,7 @@ fn test_data_conversions_polar_values() -> oso::Result<()> { // TODO (dhatch): Type handling: Would be great to be able to get each index // out here dynamically, the same way we can with result set. if let PolarValue::List(x_vec) = v_x { - assert_eq!(i64::from_polar(x_vec.get(0).unwrap().to_owned())?, 1); + assert_eq!(i64::from_polar(x_vec.first().unwrap().to_owned())?, 1); assert_eq!( String::from_polar(x_vec.get(1).unwrap().to_owned())?, String::from("two") @@ -328,7 +328,7 @@ fn test_basic_queries() { assert_eq!(results.len(), 1); assert!(results - .get(0) + .first() .map(|r| r.keys().next().is_none()) .unwrap_or_default()); } diff --git a/polar-c-api/Cargo.toml b/polar-c-api/Cargo.toml index 6821d1b493..57f17bc130 100644 --- a/polar-c-api/Cargo.toml +++ b/polar-c-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polar-c-api" -version = "0.27.2" +version = "0.27.3" authors = ["Oso Security, Inc. "] edition = "2021" @@ -10,7 +10,7 @@ crate-type = ["lib", "staticlib", "cdylib"] bench = false [dependencies] -polar-core = { path = "../polar-core", version = "=0.27.2" } +polar-core = { path = "../polar-core", version = "=0.27.3" } serde = "1.0" serde_json = "1.0.61" diff --git a/polar-core/Cargo.toml b/polar-core/Cargo.toml index e8e34479fe..6719a8e6bd 100644 --- a/polar-core/Cargo.toml +++ b/polar-core/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/osohq/oso" homepage = "https://www.osohq.com/" readme = "README.md" -version = "0.27.2" +version = "0.27.3" edition = "2021" diff --git a/polar-language-server/Cargo.toml b/polar-language-server/Cargo.toml index f1dc2066c1..e74ac3306f 100644 --- a/polar-language-server/Cargo.toml +++ b/polar-language-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polar-language-server" -version = "0.27.2" +version = "0.27.3" authors = ["Oso Security, Inc. "] edition = "2021" @@ -12,7 +12,7 @@ bench = false console_error_panic_hook = "0.1.6" js-sys = "0.3.53" lsp-types = "0.90.0" -polar-core = { path = "../polar-core", version = "=0.27.2" } +polar-core = { path = "../polar-core", version = "=0.27.3" } serde = { version = "1.0", features = ["derive"] } serde-wasm-bindgen = "0.3.1" wasm-bindgen = "0.2.76" diff --git a/polar-language-server/src/lib.rs b/polar-language-server/src/lib.rs index 7c90cb2289..fda02c1c4e 100644 --- a/polar-language-server/src/lib.rs +++ b/polar-language-server/src/lib.rs @@ -604,7 +604,7 @@ mod tests { assert_eq!(params.uri, doc.uri); assert_eq!(params.version.unwrap(), doc.version); assert_eq!(params.diagnostics.len(), 1, "{}", doc.uri); - let diagnostic = params.diagnostics.get(0).unwrap(); + let diagnostic = params.diagnostics.first().unwrap(); assert_eq!( diagnostic.message, "hit the end of the file unexpectedly. Did you forget a semi-colon" @@ -629,7 +629,7 @@ mod tests { assert_eq!(params.uri, doc.uri); assert_eq!(params.version.unwrap(), doc.version); assert_eq!(params.diagnostics.len(), 1, "{}", doc.uri); - let diagnostic = params.diagnostics.get(0).unwrap(); + let diagnostic = params.diagnostics.first().unwrap(); let expected = diagnostic .message .starts_with("Your policy does not contain an allow rule"); @@ -892,7 +892,7 @@ mod tests { // `load_documents()` API performs no filtering. let polar_diagnostics = pls.load_documents(); assert_eq!(polar_diagnostics.len(), 2, "{:?}", polar_diagnostics); - let unknown_specializer = polar_diagnostics.get(0).unwrap(); + let unknown_specializer = polar_diagnostics.first().unwrap(); let expected_message = "Unknown specializer String at line 3, column 41 of file file:///whatever.polar:\n\t003: has_permission(_: Actor, _: String, _: Resource);\n\t ^\n"; assert_eq!(unknown_specializer.to_string(), expected_message); let unregistered_class = polar_diagnostics.get(1).unwrap(); @@ -918,7 +918,7 @@ mod tests { // `load_documents()` API performs no filtering. let polar_diagnostics = pls.load_documents(); assert_eq!(polar_diagnostics.len(), 2, "{:?}", polar_diagnostics); - let unknown_specializer = polar_diagnostics.get(0).unwrap(); + let unknown_specializer = polar_diagnostics.first().unwrap(); let expected_message = "Unknown specializer B at line 4, column 18 of file file:///whatever.polar:\n\t004: f(_: B);\n\t ^\n"; assert_eq!(unknown_specializer.to_string(), expected_message); let unregistered_constant = polar_diagnostics.get(1).unwrap(); @@ -939,7 +939,7 @@ mod tests { // `load_documents()` API performs no filtering. let polar_diagnostics = pls.load_documents(); assert_eq!(polar_diagnostics.len(), 1, "{:?}", polar_diagnostics); - let singleton_variable = polar_diagnostics.get(0).unwrap(); + let singleton_variable = polar_diagnostics.first().unwrap(); assert!(singleton_variable .to_string() .starts_with("Singleton variable a is unused or undefined; try renaming to _a or _")); @@ -963,7 +963,7 @@ mod tests { assert_eq!(params.uri, doc.uri); assert_eq!(params.version.unwrap(), doc.version); assert_eq!(params.diagnostics.len(), 1); - let diagnostic = params.diagnostics.get(0).unwrap(); + let diagnostic = params.diagnostics.first().unwrap(); assert_eq!( diagnostic.message, "debug is a reserved Polar word and cannot be used here" @@ -989,7 +989,7 @@ mod tests { assert_eq!(params.uri, doc.uri); assert_eq!(params.version.unwrap(), doc.version); assert_eq!(params.diagnostics.len(), 1, "{:?}", params.diagnostics); - let undeclared_term = ¶ms.diagnostics.get(0).unwrap().message; + let undeclared_term = ¶ms.diagnostics.first().unwrap().message; assert!( undeclared_term.starts_with("Undeclared term \"read\""), "{}", @@ -1016,7 +1016,7 @@ mod tests { assert_eq!(params.uri, doc2.uri); assert_eq!(params.version.unwrap(), doc2.version); assert_eq!(params.diagnostics.len(), 1, "{:?}", params.diagnostics); - let undeclared_term = ¶ms.diagnostics.get(0).unwrap().message; + let undeclared_term = ¶ms.diagnostics.first().unwrap().message; assert_eq!( undeclared_term, &format!("Problem loading file: A file with the same contents as {} named {} has already been loaded.", doc2.uri, doc1.uri), diff --git a/polar-wasm-api/Cargo.toml b/polar-wasm-api/Cargo.toml index e114bc0e5a..3ff88086e6 100644 --- a/polar-wasm-api/Cargo.toml +++ b/polar-wasm-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polar-wasm-api" -version = "0.27.2" +version = "0.27.3" authors = ["Oso Security, Inc. "] edition = "2021" @@ -11,7 +11,7 @@ bench = false [dependencies] console_error_panic_hook = "0.1.6" js-sys = "0.3.53" -polar-core = { path = "../polar-core", version = "=0.27.2" } +polar-core = { path = "../polar-core", version = "=0.27.3" } serde = { version = "1.0.119", features = ["rc"] } serde-wasm-bindgen = "0.3.1" wasm-bindgen = "0.2.76" diff --git a/vscode/oso/package.json b/vscode/oso/package.json index a1b7839661..a112052259 100644 --- a/vscode/oso/package.json +++ b/vscode/oso/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "0.27.2", + "version": "0.27.3", "name": "oso", "displayName": "Oso", "author": "Oso Security Inc.",