Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

VEN-99 Run brakeman (#11537)

Aleksandar Petrushevaa96ebd8eda6
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 4cd0c6ef25..b7a8a802ef 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -97,6 +97,32 @@ jobs:
paths:
- ~/spree/vendor/bundle
+ brakeman:
+ <<: *defaults_3_0
+ steps:
+ - checkout
+ - restore_cache:
+ keys:
+ - spree-brakeman-{{ .Branch }}
+ - spree-brakeman
+ - run:
+ name: Ensure Bundle Install
+ command: |
+ bundle install
+ ./bin/build-ci.rb install
+ - run:
+ name: Run Brakeman spree/api
+ command: |
+ bundle exec brakeman -p api/ --skip-files app/controllers/spree/api/v1/ --exit-on-warn --exit-on-error
+ - run:
+ name: Run Brakeman spree/core
+ command: |
+ bundle exec brakeman -p core/ --ignore-config core/brakeman.ignore --exit-on-warn --exit-on-error
+ - save_cache:
+ key: spree-brakeman-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
+ paths:
+ - ~/spree/vendor/bundle
+
tests_postgres: &tests_postgres
<<: *run_tests
environment: &postgres_environment
@@ -262,6 +288,9 @@ workflows:
jobs:
- bundle
- bundle_ruby_3_0
+ - brakeman:
+ requires:
+ - bundle_ruby_3_0
- tests_postgres:
requires:
- bundle
diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rb
index 168bb58680..bdfaae8cf0 100644
--- a/common_spree_dependencies.rb
+++ b/common_spree_dependencies.rb
@@ -52,6 +52,7 @@ end
group :test, :development do
gem 'awesome_print'
+ gem 'brakeman'
gem 'gem-release'
gem 'i18n-tasks'
gem 'redis'
diff --git a/core/app/models/concerns/spree/product_scopes.rb b/core/app/models/concerns/spree/product_scopes.rb
index a1531af78f..c46b3879a4 100644
--- a/core/app/models/concerns/spree/product_scopes.rb
+++ b/core/app/models/concerns/spree/product_scopes.rb
@@ -27,7 +27,7 @@ module Spree
next if name.to_s.include?('master_price')
parts = name.to_s.match(/(.*)_by_(.*)/)
- scope(name.to_s, -> { order(Arel.sql("#{Product.quoted_table_name}.#{parts[2]} #{parts[1] == 'ascend' ? 'ASC' : 'DESC'}")) })
+ scope(name.to_s, -> { order(Arel.sql(sanitize_sql("#{Product.quoted_table_name}.#{parts[2]} #{parts[1] == 'ascend' ? 'ASC' : 'DESC'}"))) })
end
end
@@ -162,7 +162,7 @@ module Spree
else
if OptionType.column_for_attribute('id').type == :uuid
OptionType.where(id: option).or(OptionType.where(name: option))&.first&.id
- else
+ else
OptionType.where(name: option)&.first&.id
end
end
diff --git a/core/brakeman.ignore b/core/brakeman.ignore
new file mode 100644
index 0000000000..c82e0794ed
--- /dev/null
+++ b/core/brakeman.ignore
@@ -0,0 +1,20 @@
+{
+ "ignored_warnings": [
+ {
+ "fingerprint": "011b2643940ba1112f7a737e403abe3616ad91764703c801cc35a48d36b721da",
+ "note": "interpolating table name"
+ },
+ {
+ "fingerprint": "965d3919f811ab63b7b8d62da528559a7f38dc122c57efea7136e7ec5ef1f062",
+ "note": "interpolating table name"
+ },
+ {
+ "fingerprint": "abd8e90e7a7dfbcdcd6d44fd3fb550598aee6d7a9ef2bb132ad1a18a3c50be30",
+ "note": "interpolating table name"
+ },
+ {
+ "fingerprint": "efcc57e1a5648d7db59d1beaf5e399d2278539a8667b19c520b305a6ca7e15e8",
+ "note": "interpolating table name"
+ }
+ ]
+}