-
Notifications
You must be signed in to change notification settings - Fork 287
feat: add vulnerability report form #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
martinjagodic
wants to merge
9
commits into
main
Choose a base branch
from
vulnerability-form
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+381
−21
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
203a743
feat: add vulnerability report form, some related refactoring
martinjagodic 6a82026
trigger form detection
martinjagodic 1d275e1
change form name
martinjagodic 7b8884e
update hugo version
martinjagodic 40c7f6c
Apply suggestions from code review
martinjagodic d11f0ff
fix: pr comments, page hero to features layout
martinjagodic 5ff3c06
Apply suggestions from code review
martinjagodic 490068c
remove some content, reorder files
martinjagodic fb266db
Apply suggestions from code review
martinjagodic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Vulnerability Report Form Handler | ||
| */ | ||
|
|
||
| const form = document.getElementById('vulnerability-form') | ||
|
|
||
| function handleVulnerabilityFormSubmit (event) { | ||
| event.preventDefault() | ||
|
|
||
| const submitButton = document.getElementById('submit-button') | ||
| const errorMessage = document.getElementById('error-message') | ||
| const errorText = document.getElementById('error-text') | ||
| const successMessage = document.getElementById('success-message') | ||
|
|
||
| errorMessage.classList.add('is-hidden') | ||
| successMessage.classList.add('is-hidden') | ||
|
|
||
| submitButton.disabled = true | ||
|
|
||
| const formData = new FormData(form) | ||
|
|
||
| fetch('/', { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, | ||
| body: new URLSearchParams(formData).toString(), | ||
| }) | ||
| .then((res) => { | ||
| if (!res.ok) { | ||
| throw new Error(`HTTP error! status: ${res.status}`) | ||
| } | ||
| submitButton.disabled = false | ||
| form.classList.add('is-hidden') | ||
| successMessage.classList.remove('is-hidden') | ||
| successMessage.scrollIntoView({ behavior: 'smooth', block: 'start' }) | ||
| }) | ||
| .catch((error) => { | ||
| console.error('Form submission error:', error) | ||
| errorText.textContent = 'Error submitting report. Please try again or contact us directly if the problem persists.' | ||
| errorMessage.classList.remove('is-hidden') | ||
| submitButton.disabled = false | ||
| errorMessage.scrollIntoView({ behavior: 'smooth', block: 'start' }) | ||
| }) | ||
| } | ||
|
|
||
| form?.addEventListener('submit', handleVulnerabilityFormSubmit) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,8 @@ img { | |
|
|
||
| iframe { | ||
| width: 100%; | ||
| } | ||
|
|
||
| .is-hidden { | ||
| display: none !important; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| // Generic form element styles | ||
|
|
||
| form { | ||
| display: flex; | ||
| flex-direction: column; | ||
| margin-bottom: var(--space-6); | ||
| } | ||
|
|
||
| input[type="text"], | ||
| input[type="email"], | ||
| input[type="password"], | ||
| textarea { | ||
| padding: var(--space-2) var(--space-3); | ||
| font-size: var(--font-size-md); | ||
| font-family: var(--font-family-primary); | ||
| border: 1px solid var(--color-lightest-gray); | ||
| border-radius: var(--radius-md); | ||
| background-color: var(--color-white); | ||
|
|
||
| &:focus { | ||
| outline: none; | ||
| border-color: var(--color-blue); | ||
| box-shadow: 0 0 0 2px rgba(58, 105, 199, 0.1); | ||
| } | ||
| } | ||
|
|
||
| textarea { | ||
| resize: vertical; | ||
| min-height: 100px; | ||
| } | ||
|
|
||
| input[type="checkbox"] { | ||
|
|
||
| margin: 0; | ||
| width: 16px; | ||
| height: 16px; | ||
| } | ||
|
|
||
| .form-element { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--space-2); | ||
| margin-bottom: var(--space-4); | ||
|
|
||
| span { | ||
| font-weight: var(--font-weight-medium); | ||
| font-size: var(--font-size-md); | ||
| } | ||
|
|
||
| &:has(input:required, textarea:required) { | ||
| span:after { | ||
| content: ' *'; | ||
| color: var(--color-primary-light); | ||
| } | ||
| } | ||
|
|
||
| small { | ||
| font-size: var(--font-size-sm); | ||
| color: var(--color-lightish-gray); | ||
| } | ||
|
|
||
| &--checkbox { | ||
| label { | ||
| display: flex; | ||
| gap: var(--space-2); | ||
| align-items: center; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| button[type="submit"] { | ||
| align-self: flex-start; | ||
| } | ||
|
|
||
| // Message containers | ||
| .form-success, | ||
| .form-error { | ||
| padding: var(--space-3) var(--space-4); | ||
| border-radius: var(--radius-md); | ||
| margin: var(--space-4) 0; | ||
| } | ||
|
|
||
| .form-success { | ||
| background-color: #e8f5e9; | ||
| border-left: 4px solid #388e3c; | ||
| color: #1b5e20; | ||
|
|
||
| h3 { | ||
| margin-top: 0; | ||
| color: #1b5e20; | ||
| } | ||
|
|
||
| p { | ||
| margin: var(--space-2) 0; | ||
| color: #2e7d32; | ||
| } | ||
| } | ||
|
|
||
| .form-error { | ||
| background-color: #fce4ec; | ||
| border-left: 4px solid #d32f2f; | ||
| color: #c62828; | ||
|
|
||
| p { | ||
| margin: 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .page-hero { | ||
| margin-bottom: var(--space-6); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
|
|
||
| &__form { | ||
| width: 100%; | ||
| margin: 0; | ||
| } | ||
|
|
||
| &__field { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,3 @@ | ||
| .community-header { | ||
| margin-bottom: var(--space-6); | ||
| } | ||
|
|
||
| .community-section { | ||
| margin-bottom: var(--space-6); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: Report a Security Vulnerability | ||
| description: You can confidentially report security vulnerabilities in Decap CMS by filling out this form. Do not open public GitHub issues for security vulnerabilities! | ||
| layout: report-vulnerability | ||
| success_title: Thank You for Your Report | ||
| success_message: We've received your vulnerability submission. We'll investigate it and work with you to understand the problem. If confirmed, we'll coordinate a fix and responsible disclosure with you. | ||
| button_text: Submit Vulnerability Report | ||
| form_fields: | ||
| title: | ||
| label: Vulnerability Title | ||
| placeholder: e.g., XSS vulnerability in markdown widget | ||
| help: Brief summary of the security issue (max 200 characters) | ||
| maxlength: 200 | ||
| description: | ||
| label: Detailed Description | ||
| placeholder: Describe what the vulnerability is and why it's a security concern... | ||
| help: Explain the vulnerability in detail, including how it occurs (10-5000 characters) | ||
| minlength: 10 | ||
| maxlength: 5000 | ||
| versions: | ||
| label: Affected Version(s) | ||
| placeholder: e.g., 3.0.0, 3.1.x | ||
| help: Which version(s) of Decap CMS are affected? | ||
| steps: | ||
| label: Steps to Reproduce | ||
| placeholder: "1. Start Decap CMS with...\n2. Navigate to...\n3. Observe..." | ||
| help: Clear, numbered steps to demonstrate the vulnerability (optional, max 3000 characters) | ||
| maxlength: 3000 | ||
| impact: | ||
| label: Potential Impact | ||
| placeholder: This vulnerability could allow attackers to... | ||
| help: What is the impact of this vulnerability? (e.g., data exposure, unauthorized access, content integrity) | ||
| maxlength: 2000 | ||
| name: | ||
| label: Your Name | ||
| maxlength: 100 | ||
| email: | ||
| label: Your Email | ||
| placeholder: your@email.com | ||
| help: We'll use this to acknowledge receipt and follow up with you. We won't share it without your consent. | ||
| credit: | ||
| label: I would like public credit for this report | ||
| help: Your name will appear in the GitHub Security Advisory and release notes (unless you provide alternate details) | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| {{ define "main" }} | ||
| <div class="page"> | ||
| <div class="container size-sm"> | ||
| {{ partial "page-hero" . }} | ||
|
|
||
| {{ partial "vulnerability-report-form" . }} | ||
|
|
||
| {{ with .Content }} | ||
| <div class="markdown"> | ||
| {{ . }} | ||
| </div> | ||
| {{ end }} | ||
| </div> | ||
| </div> | ||
| {{ end }} | ||
|
|
||
| {{ define "scripts" }} | ||
| {{ $formJS := resources.Get "/scripts/vulnerability-form.js" | js.Build (dict "minify" true) }} | ||
| <script defer src="{{ $formJS.RelPermalink }}"></script> | ||
| {{ end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <div class="page-hero"> | ||
| <h1>{{ .Title }}</h1> | ||
|
|
||
| {{ with .Description }} | ||
| <p class="lead">{{ . }}</p> | ||
| {{ end }} | ||
| </div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to reenable the button in the success case since the form is going to be hidden