
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
hmvc-rails is the high-level model of MVC (MVC high-level structure)
hmvc-rails makes it easy to manage source code and develop projects
Add this line to your application's Gemfile
gem 'hmvc-rails', '1.0.3', group: :development
Then execute
bundle install
And run
rails g hmvc_rails:install
create config/initializers/hmvc.rb
create app/operations/application_operation.rb
create app/forms/application_form.rb
create app/validators/uniqueness_validator.rb
create app/validators/email_validator.rb
If it's an API project then you can run
rails g hmvc_rails:install --api
create config/initializers/hmvc_rails.rb
create app/operations/application_operation.rb
create app/forms/application_form.rb
create app/validators/uniqueness_validator.rb
create app/validators/email_validator.rb
create lib/hmvc_rails/extras/exception.rb
create lib/hmvc_rails/extras/error_resource.rb
create lib/hmvc_rails/extras/error_response.rb
insert config/application.rb
insert app/controllers/application_controller.rb
rails g hmvc_rails controller_name
hmvc controller_name
Example
rails g hmvc_rails admin
---
OR
hmvc admin
create app/controllers/admin_controller.rb
create app/operations/admin/index_operation.rb
create app/operations/admin/show_operation.rb
create app/operations/admin/new_operation.rb
create app/operations/admin/create_operation.rb
create app/operations/admin/edit_operation.rb
create app/operations/admin/update_operation.rb
create app/operations/admin/destroy_operation.rb
create app/forms/admin/new_form.rb
create app/forms/admin/create_form.rb
create app/forms/admin/edit_form.rb
create app/forms/admin/update_form.rb
create app/views/admin/index.html.erb
create app/views/admin/show.html.erb
create app/views/admin/new.html.erb
create app/views/admin/edit.html.erb
--action
rails g hmvc_rails admin --action index show list detail selection
--form
rails g hmvc_rails admin --action index show list detail selection --form index show list
--parent-controller
rails g hmvc_rails admin --parent-controller PersonController
--skip-form
rails g hmvc_rails admin --skip-form
Or change configuration config.form = %w[]
--skip-view
rails g hmvc_rails admin --skip-view
Or change configuration config.view = %w[]
If you want to change the default value when creating the file, please uncomment and update
config/initializers/hmvc.rb
# frozen_string_literal: true
# Created at: 2023-02-18 22:30 +0700
# Creator: thuc.phan@tomosia.com
if Rails.env.development?
Hmvc::Rails.configure do |config|
# The controller files's parent class of controller. Default is ApplicationController
# config.parent_controller = "ApplicationController"
# Method when creating the controller files. Default is %w[index show new create edit update destroy]
# config.action = %w[index show new create edit update destroy]
# Method when creating the view files. Default is %w[index show new edit]
# config.view = %w[index show new edit]
# The form files's parent class. Default is ApplicationForm
# config.parent_form = "ApplicationForm"
# Method when creating the form files. Default is %w[new create edit update]
# config.form = %w[new create edit update]
# The operation files's parent class. Default is ApplicationOperation
# config.parent_operation = "ApplicationOperation"
# Save author name and timestamp to file. Default is true
# config.file_traces = true
end
end
If you want to rollback the hmvc-rails generator. You can run command
rails d hmvc_rails controller_name
bundle
(link to gem hmvc-rails project)group :development do
gem 'hmvc-rails', path: '../../Projects/hmvc-rails'
gem 'pry'
end
binding.pry
to the line you want to testrequire 'pry'
...
def create_controller
binding.pry
template "controller.rb", File.join("app/controllers", class_path.join("/"), "#{file_name}_controller.rb")
end
rails g hmvc_rails admin
37: def create_controller
=> 38: binding.pry
39: template "controllers/controller.rb",
40: File.join("app/controllers", class_path.join("/"), "#{file_name}_controller.rb")
41: end
[1] pry(#<HmvcRailsGenerator>)> options[:action]
=> ["index", "show", "new", "create", "edit", "update", "destroy"]
[2] pry(#<HmvcRailsGenerator>)>
➜ hmvc-rails git:(main) rubocop
Inspecting 14 files
..............
14 files inspected, no offenses detected
➜ hmvc-rails git:(main) ✗ rake test
Run options: --seed 9122
# Running:
.............
Finished in 0.721364s, 18.0214 runs/s, 166.3515 assertions/s.
13 runs, 120 assertions, 0 failures, 0 errors, 0 skips
If your project used rubocop for code convention. You can add the below configuration for some conventional hmvc-rails
.rubocop.yml
require: rubocop/cop/hmvc_rails_cops
HmvcRails/OperatingStyle:
Enabled: true
Include:
- app/operations/**/*.rb
HmvcRails/FormalStyle:
Enabled: true
Include:
- app/forms/**/*.rb
Example hmvc-rails offenses
➜ demo git:(master) ✗ rubocop
Inspecting 48 files
......C......C..................................
Offenses:
app/forms/admin/new_form.rb:6:1: C: HmvcRails/FormalStyle: The form filename does not match the desired format
class Admin::NewFormm < ApplicationForm ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/operations/admin/new_operation.rb:6:1: C: HmvcRails/OperatingStyle: The operation filename does not match the desired format
class Admin::NewOperationn < ApplicationOperation ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/operations/admin/new_operation.rb:7:3: C: HmvcRails/OperatingStyle: Method works in "call" without prefix "step_"
def call ...
^^^^^^^^
48 files inspected, 3 offenses detected
The gem hmvc-rails
is copyright TOMOSIA VIET NAM CO., LTD
A company that creates new value together with customers and lights the light of happiness
【一緒に】【ハッピー】【ライトアップ】
お客様と共に新たな価値を生み出し幸せの明かりを灯す会社、トモシア
FAQs
Unknown package
We found that hmvc-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.