jekyll-content-security-policy-generator 1.6.10 → 1.6.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +128 -0
- data/README.md +8 -0
- data/lib/jekyll-content-security-policy-generator/hook.rb +20 -13
- data/lib/jekyll-content-security-policy-generator/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51ac58de24c4823f70c76389c591fa79c380808a053d4cf27550c5f2b4a6c171
|
4
|
+
data.tar.gz: 16c7ae6382f5161e93f3c31ef95d9da7d317a24aa614d92f4d7649489623dcbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf7182c08e98b06678d3900fc4990d49e7c552c7644f077fa3c770642732d7b1303239d486053ed71cad85ee72cc00c83210b30e6cf31642d56871ec5c2fefec
|
7
|
+
data.tar.gz: db7b299bae6fe8b6d838600b612cdb89904cb7fe837358d8da56ed28f0d40c1ad180cc132592c3bdf8febfbdd05058a7ca48d42db080d83ddcc37d9af2d9a40a
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
10
|
+
and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
26
|
+
overall community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
31
|
+
advances of any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email
|
35
|
+
address, without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
.
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
86
|
+
of actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
93
|
+
permanent ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
113
|
+
the community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.0, available at
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
123
|
+
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
125
|
+
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
128
|
+
https://www.contributor-covenant.org/translations.
|
data/README.md
CHANGED
@@ -20,6 +20,14 @@ To speed up development of Jekyll based sites whilst also helping to generate se
|
|
20
20
|
* Creates or reuses an HTTP meta tag for the content security policy.
|
21
21
|
* Finds all images, styles, scripts and frames with external URLs and builds CSP.
|
22
22
|
* Converts style attributes into ```<style>``` elements.
|
23
|
+
* If a page already has a content-security-policy tag, (such as your index.html file), the script will reuse it.
|
24
|
+
* Image URLs such as https://strongscot.com/images/logo.svg will have a rule such as https://strongscot.com/images/
|
25
|
+
|
26
|
+
## Upcoming Features
|
27
|
+
|
28
|
+
* Ability to specify how lax the domain rules can be. For example, ```https://strongscot.com/images/logo.svg``` would be converted to
|
29
|
+
```https://strongscot.com/images/``` under strict and ```https://strongscot.com``` under relaxed.
|
30
|
+
* Ability in site.yaml file to specify what files it should parse, at the moment its only ```.html```.
|
23
31
|
|
24
32
|
## Installation
|
25
33
|
|
@@ -43,7 +43,6 @@ module Jekyll
|
|
43
43
|
end
|
44
44
|
|
45
45
|
if @csp_image_src.length > 0
|
46
|
-
Jekyll.logger.warn @csp_image_src
|
47
46
|
meta_content += "img-src " + @csp_image_src.join(' ') + '; '
|
48
47
|
end
|
49
48
|
|
@@ -64,10 +63,10 @@ module Jekyll
|
|
64
63
|
end
|
65
64
|
|
66
65
|
if @nokogiri.at("head")
|
67
|
-
|
66
|
+
Jekyll.logger.info "Generated content security policy, inserted in HEAD."
|
68
67
|
@nokogiri.at("head") << "<meta http-equiv=\"Content-Security-Policy\" content=\"" + meta_content + "\">"
|
69
68
|
elsif @nokogiri.at("body")
|
70
|
-
|
69
|
+
Jekyll.logger.info "Generated content security policy, inserted in BODY."
|
71
70
|
@nokogiri.at("body") << "<meta http-equiv=\"Content-Security-Policy\" content=\"" + meta_content + "\">"
|
72
71
|
else
|
73
72
|
Jekyll.logger.error "Generated content security policy but found no-where to insert it."
|
@@ -95,7 +94,7 @@ module Jekyll
|
|
95
94
|
@csp_script_src.concat(policy_parts.drop(1))
|
96
95
|
elsif policy_parts[0] == 'style-src'
|
97
96
|
@csp_style_src.concat(policy_parts.drop(1))
|
98
|
-
elsif policy_parts[0] == '
|
97
|
+
elsif policy_parts[0] == 'img-src'
|
99
98
|
@csp_image_src.concat(policy_parts.drop(1))
|
100
99
|
elsif policy_parts[0] == 'frame-src'
|
101
100
|
@csp_frame_src.concat(policy_parts.drop(1))
|
@@ -107,6 +106,10 @@ module Jekyll
|
|
107
106
|
Jekyll.logger.warn "Incorrect existing content security policy meta tag found, skipping."
|
108
107
|
end
|
109
108
|
end
|
109
|
+
|
110
|
+
@nokogiri.search('meta[http-equiv="Content-Security-Policy"]').each do |el|
|
111
|
+
el.remove
|
112
|
+
end
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
@@ -120,7 +123,8 @@ module Jekyll
|
|
120
123
|
if find.attr('id')
|
121
124
|
element_id = find.attr('id')
|
122
125
|
else
|
123
|
-
|
126
|
+
hash = Digest::MD5.hexdigest find_src + "#{Random.rand(11)}"
|
127
|
+
element_id = "csp-gen-" + hash
|
124
128
|
find["id"] = element_id
|
125
129
|
end
|
126
130
|
|
@@ -129,11 +133,11 @@ module Jekyll
|
|
129
133
|
|
130
134
|
if @nokogiri.at('head')
|
131
135
|
@nokogiri.at('head') << new_element
|
132
|
-
|
136
|
+
Jekyll.logger.info'Converting style attribute to inline style, inserted into HEAD.'
|
133
137
|
else
|
134
138
|
if @nokogiri.at('body')
|
135
139
|
@nokogiri.at('body') << new_element
|
136
|
-
|
140
|
+
Jekyll.logger.info'Converting style attribute to inline style, inserted into BODY.'
|
137
141
|
else
|
138
142
|
Jekyll.logger.warn'Unable to convert style attribute to inline style, no HEAD or BODY found.'
|
139
143
|
end
|
@@ -148,7 +152,7 @@ module Jekyll
|
|
148
152
|
@nokogiri.css('img').each do |find|
|
149
153
|
find_src = find.attr('src')
|
150
154
|
|
151
|
-
if find_src.start_with?('http', 'https')
|
155
|
+
if find_src and find_src.start_with?('http', 'https')
|
152
156
|
@csp_image_src.push find_src.match(/(.*\/)+(.*$)/)[1]
|
153
157
|
end
|
154
158
|
end
|
@@ -174,7 +178,7 @@ module Jekyll
|
|
174
178
|
if find.attr('src')
|
175
179
|
find_src = find.attr('src')
|
176
180
|
|
177
|
-
if find_src.start_with?('http', 'https')
|
181
|
+
if find_src and find_src.start_with?('http', 'https')
|
178
182
|
@csp_script_src.push find_src.match(/(.*\/)+(.*$)/)[1]
|
179
183
|
end
|
180
184
|
|
@@ -191,7 +195,7 @@ module Jekyll
|
|
191
195
|
if find.attr('src')
|
192
196
|
find_src = find.attr('src')
|
193
197
|
|
194
|
-
if find_src.start_with?('http', 'https')
|
198
|
+
if find_src and find_src.start_with?('http', 'https')
|
195
199
|
@csp_style_src.push find_src.match(/(.*\/)+(.*$)/)[1]
|
196
200
|
end
|
197
201
|
|
@@ -207,7 +211,7 @@ module Jekyll
|
|
207
211
|
@nokogiri.css('iframe').each do |find|
|
208
212
|
find_src = find.attr('src')
|
209
213
|
|
210
|
-
if find_src.start_with?('http', 'https')
|
214
|
+
if find_src and find_src.start_with?('http', 'https')
|
211
215
|
@csp_frame_src.push find_src.match(/(.*\/)+(.*$)/)[1]
|
212
216
|
end
|
213
217
|
end
|
@@ -257,12 +261,14 @@ module Jekyll
|
|
257
261
|
# Write document contents
|
258
262
|
def write(dest)
|
259
263
|
dest_path = destination(dest)
|
264
|
+
|
260
265
|
if File.extname(dest_path) == ".html"
|
261
266
|
content_security_policy_generator = ContentSecurityPolicyGenerator.new output
|
262
|
-
|
267
|
+
self.write_file_contents(dest_path, content_security_policy_generator.run)
|
268
|
+
else
|
269
|
+
self.write_file_contents(dest_path, output)
|
263
270
|
end
|
264
271
|
|
265
|
-
write_file_contents(dest_path, output)
|
266
272
|
end
|
267
273
|
|
268
274
|
end
|
@@ -285,6 +291,7 @@ module Jekyll
|
|
285
291
|
# Write page contents
|
286
292
|
def write(dest)
|
287
293
|
super dest
|
294
|
+
|
288
295
|
Jekyll::Hooks.trigger hook_owner, :post_write, self
|
289
296
|
end
|
290
297
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-content-security-policy-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- strongscot
|
@@ -105,6 +105,7 @@ extensions: []
|
|
105
105
|
extra_rdoc_files: []
|
106
106
|
files:
|
107
107
|
- ".gitignore"
|
108
|
+
- CODE_OF_CONDUCT.md
|
108
109
|
- Cover.png
|
109
110
|
- LICENSE
|
110
111
|
- Makefile
|