blazer-plus 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/lib/blazer/plus/queries_controller.rb +41 -0
- data/lib/blazer/plus/railtie.rb +16 -0
- data/lib/blazer/plus/version.rb +7 -0
- data/lib/blazer/plus.rb +17 -0
- data/sig/blazer/plus.rbs +6 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c8f6d7b6badc12fef2efb2b24d1f870cd67a9b27f035032e227d5769a6049702
|
4
|
+
data.tar.gz: e24a31f0150e99dabbc0bfe402f2b06549f1bcdaa4740b40c2bc3d82e4fdbb05
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 678952e274cbdd82169388f508a605bff3956c4ca7e781b5e0e7441d4de420df79d08cd08924045766821004268f2285db1af9faf8aedc188584f27d3b7665da
|
7
|
+
data.tar.gz: 20def0822fc82bec0b249e6d9c07b21ba9f044a027f8cdee2af2d93878043ed05151a8ed1301a36ed700ba815cb103e046d2a6044e5488432b5f3db9d5430a6d
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lala.akira@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 aki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Blazer Plus
|
2
|
+
|
3
|
+
Blazer Plus is a feature extension for the [blazer](https://github.com/ankane/blazer) gem.
|
4
|
+
It provides additional safety measures and enhancements to improve user experience and security when using Blazer for database queries.
|
5
|
+
|
6
|
+
- Support for CSV output with BOM
|
7
|
+
- Row limit for query result output
|
8
|
+
- Access restriction for dangerous actions
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'blazer-plus'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
You can configure Blazer Plus in your application's initialization file.
|
27
|
+
Here's an example:
|
28
|
+
|
29
|
+
```ruby:config/initializers/blazer.rb
|
30
|
+
# Blazer::Plus.enabled = true
|
31
|
+
Blazer::Plus.blazer_danger_actionable_method = ->(blazer_user) { blazer_user.blazer_admin? }
|
32
|
+
```
|
33
|
+
|
34
|
+
In this example, `Blazer::Plus.enabled` is a flag to enable or disable the Blazer Plus features.
|
35
|
+
`Blazer::Plus.blazer_danger_actionable_method` is a lambda function that you can customize to handle dangerous queries action by Blazer Plus.
|
36
|
+
|
37
|
+
## License
|
38
|
+
This gem is available under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
|
5
|
+
module Blazer
|
6
|
+
module Plus
|
7
|
+
module QueriesController
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
DEFAULT_ROW_LIMIT = 5000
|
11
|
+
|
12
|
+
prepended do
|
13
|
+
before_action :blazer_danger_actionable!, only: %i[new edit create update destroy]
|
14
|
+
end
|
15
|
+
|
16
|
+
# NOTE: Support BOM for Excel
|
17
|
+
def csv_data(columns, rows, data_source)
|
18
|
+
"\xEF\xBB\xBF#{super}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# NOTE: Support row_limit setting for HTML
|
22
|
+
def render_run
|
23
|
+
row_limit = Blazer.settings.fetch('row_limit', DEFAULT_ROW_LIMIT)
|
24
|
+
if request.format == :html && row_limit
|
25
|
+
@row_limit ||= row_limit
|
26
|
+
end
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def blazer_danger_actionable!
|
34
|
+
if !blazer_user || !Blazer::Plus.blazer_danger_actionable_method.respond_to?(:call) || !Blazer::Plus.blazer_danger_actionable_method.call(blazer_user)
|
35
|
+
Rails.logger.warn "BlazerQueriesController##{action_name} was forbidden for #{blazer_user.inspect}"
|
36
|
+
render plain: '403 Forbidden', status: :forbidden
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/railtie'
|
4
|
+
require_relative 'queries_controller'
|
5
|
+
|
6
|
+
module Blazer
|
7
|
+
module Plus
|
8
|
+
class Railtie < ::Rails::Railtie
|
9
|
+
initializer :initialize_blazer_plus, after: :load_config_initializers do
|
10
|
+
Rails.application.reloader.to_prepare do
|
11
|
+
::Blazer::QueriesController.prepend(::Blazer::Plus::QueriesController) if ::Blazer::Plus.enabled
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/blazer/plus.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'plus/version'
|
4
|
+
require_relative 'plus/railtie'
|
5
|
+
|
6
|
+
module Blazer
|
7
|
+
module Plus
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :enabled, :blazer_danger_actionable_method
|
12
|
+
end
|
13
|
+
|
14
|
+
self.enabled = true
|
15
|
+
self.blazer_danger_actionable_method = nil
|
16
|
+
end
|
17
|
+
end
|
data/sig/blazer/plus.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blazer-plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- aki77
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: blazer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Blazer Plus is a feature extension for the Blazer gem. It provides additional
|
42
|
+
safety measures and enhancements to improve the user experience and security when
|
43
|
+
using Blazer for database queries.
|
44
|
+
email:
|
45
|
+
- aki77@users.noreply.github.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".rspec"
|
51
|
+
- ".rubocop.yml"
|
52
|
+
- CHANGELOG.md
|
53
|
+
- CODE_OF_CONDUCT.md
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/blazer/plus.rb
|
58
|
+
- lib/blazer/plus/queries_controller.rb
|
59
|
+
- lib/blazer/plus/railtie.rb
|
60
|
+
- lib/blazer/plus/version.rb
|
61
|
+
- sig/blazer/plus.rbs
|
62
|
+
homepage: https://github.com/SonicGarden/blazer-plus
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata:
|
66
|
+
homepage_uri: https://github.com/SonicGarden/blazer-plus
|
67
|
+
source_code_uri: https://github.com/SonicGarden/blazer-plus/
|
68
|
+
changelog_uri: https://github.com/SonicGarden/blazer-plus/releases
|
69
|
+
rubygems_mfa_required: 'true'
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 3.1.0
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.4.10
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Feature extension for safely using Blazer
|
89
|
+
test_files: []
|