Skip to content

Commit

Permalink
Added new template: security vulnerability report for Github
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenouw committed Aug 11, 2019
1 parent 85728f4 commit faa4bf3
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 25 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ More files & providers in future versions.

### Github specific
* Bug report (issue)
* Security vulnerability report
* Feature request (issue)
* Pull request template
* All files at once
Expand Down Expand Up @@ -96,11 +97,11 @@ GENERATE: CONTRIBUTING.md...
GENERATE: bug_report.md...
GENERATE: feature_request.md...
GENERATE: pull_request_template.md...
CREATE: bug_report.md in <path-to-folder>/.github/ISSUE_TEMPLATE/bug_report.md
CREATE: CODE_OF_CONDUCT.md in <path-to-folder>/CODE_OF_CONDUCT.md.md
CREATE: CONTRIBUTING.md in <path-to-folder>/CONTRIBUTING.md
CREATE: feature_request.md in <path-to-folder>/.github/ISSUE_TEMPLATE/feature_request.md
CREATE: pull_request_template.md in <path-to-folder>/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
CREATE: bug_report.md in .github/ISSUE_TEMPLATE/bug_report.md
CREATE: CODE_OF_CONDUCT.md in CODE_OF_CONDUCT.md.md
CREATE: CONTRIBUTING.md in CONTRIBUTING.md
CREATE: feature_request.md in .github/ISSUE_TEMPLATE/feature_request.md
CREATE: pull_request_template.md in .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
```

Git provider question:
Expand Down Expand Up @@ -131,7 +132,7 @@ Generate license example:
GENERATE: LICENSE...
? Which type of license do you want to generate? MIT License
? Please fill in your Git username: Jeroenouw
CREATE: LICENSE in <path-to-folder>/LICENSE
CREATE: LICENSE in LICENSE
```

File already exists example:
Expand All @@ -140,5 +141,5 @@ File already exists example:
? Which Bitbucket files do you want to generate? Contributing
GENERATE: CONTRIBUTING.md...
? This file already exists. Do you want to overwrite it? Yes
UPDATE: CONTRIBUTING.md in <path-to-folder>/CONTRIBUTING.md
UPDATE: CONTRIBUTING.md in CONTRIBUTING.md
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cgx",
"version": "1.8.1",
"version": "1.9.0",
"description": "Generate all the recommended markdown documentation/templates (pre-filled) for the Github, Gitlab and Bitbucket community standards",
"author": "Jeroen Ouwehand",
"repository": "https://github.com/jeroenouw/cgx",
Expand Down
6 changes: 5 additions & 1 deletion src/cgx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable, inject } from 'inversify';
import { Logger } from './utils/logger.util';
import { CodeOfConduct, Contributing, License, ToDo, Readme, Changelog } from './templates/universal';
import { BugReport, FeatureRequest, PullRequest } from './templates/github';
import { BugReport, FeatureRequest, PullRequest, Security } from './templates/github';
import { UniversalChoiceValue, GithubChoiceValue, GitlabChoiceValue, Answer, ProviderValue } from './models/choice';
import { Bug, CITemplate, FeatureProposal, MergeRequest } from './templates/gitlab';
import { providerQuestion, githubFileQuestion, gitlabFileQuestion, bitbucketFileQuestion } from './questions';
Expand All @@ -21,6 +21,7 @@ export class CGX {
@inject('Bug') private bug: Bug,
@inject('FeatureProposal') private featureProposal: FeatureProposal,
@inject('ToDo') private todo: ToDo,
@inject('Security') private security: Security,
@inject('Readme') private readme: Readme,
@inject('Changelog') private changelog: Changelog,
@inject('CITemplate') private ciTemplate: CITemplate) {
Expand Down Expand Up @@ -71,6 +72,9 @@ export class CGX {
case UniversalChoiceValue.README: {
return this.readme.generateFile();
}
case GithubChoiceValue.SECURITY: {
return this.security.generateFile();
}
case GithubChoiceValue.BUG_REPORT: {
return this.bugReport.generateFile();
}
Expand Down
17 changes: 4 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ import 'reflect-metadata';
import { Container } from 'inversify';
import { CGX } from './cgx';
import { Logger } from './utils/logger.util';
import { CodeOfConduct } from './templates/universal/code-of-conduct.template';
import { License } from './templates/universal/license.template';
import { Checker } from './utils/checker.util';
import { Contributing } from './templates/universal/contributing.template';
import { BugReport } from './templates/github/bug-report.template';
import { FeatureRequest } from './templates/github/feature-request.template';
import { PullRequest } from './templates/github/pull-request.template';
import { DefaultTemplate } from './templates/default/default.template';
import { MergeRequest } from './templates/gitlab/merge-request.template';
import { Bug } from './templates/gitlab/bug.template';
import { CITemplate } from './templates/gitlab/ci.template';
import { FeatureProposal } from './templates/gitlab/feature-proposal.template';
import { ToDo } from './templates/universal/todo.template';
import { Readme } from './templates/universal/readme.template';
import { Changelog } from './templates/universal/changelog.template';
import { CodeOfConduct, Contributing, License, ToDo, Readme, Changelog } from './templates/universal';
import { BugReport, FeatureRequest, PullRequest, Security } from './templates/github';
import { Bug, CITemplate, FeatureProposal, MergeRequest } from './templates/gitlab';

export function index(): CGX {
const container: Container = new Container();
Expand All @@ -40,6 +30,7 @@ export function index(): CGX {
container.bind<BugReport>('BugReport').to(BugReport).inSingletonScope();
container.bind<FeatureRequest>('FeatureRequest').to(FeatureRequest).inSingletonScope();
container.bind<PullRequest>('PullRequest').to(PullRequest).inSingletonScope();
container.bind<Security>('Security').to(Security).inSingletonScope();

// Gitlab Templates
container.bind<CITemplate>('CITemplate').to(CITemplate).inSingletonScope();
Expand Down
1 change: 1 addition & 0 deletions src/models/choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum GithubChoiceValue {
BUG_REPORT = 'BUG_REPORT',
FEATURE_REQUEST = 'FEATURE_REQUEST',
PULL_REQUEST = 'PULL_REQUEST',
SECURITY = 'SECURITY',
}

export enum GitlabChoiceValue {
Expand Down
1 change: 1 addition & 0 deletions src/models/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export enum FileName {
README = 'README.md',
TODO = 'TODO.md',
CHANGELOG = 'CHANGELOG.md',
SECURITY = 'SECURITY.md',
}
2 changes: 1 addition & 1 deletion src/questions/bitbucket-file.question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Answer, UniversalChoiceValue, Choice } from '../models/choice';

export async function bitbucketFileQuestion(): Promise<Answer> {
const listOfFiles: Choice[] = [
{name: 'All main files (without license, changelog, todo and readme)', value: UniversalChoiceValue.ALL},
{name: 'All recommended files (other files can be generated separate)', value: UniversalChoiceValue.ALL},
{name: 'License', value: UniversalChoiceValue.LICENSE},
{name: 'Changelog', value: UniversalChoiceValue.CHANGELOG},
{name: 'Contributing', value: UniversalChoiceValue.CONTRIBUTING},
Expand Down
3 changes: 2 additions & 1 deletion src/questions/github-file.question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { Answer, UniversalChoiceValue, GithubChoiceValue, Choice } from '../mode

export async function githubFileQuestion(): Promise<Answer> {
const listOfFiles: Choice[] = [
{name: 'All main files (without license, changelog, todo and readme)', value: UniversalChoiceValue.ALL},
{name: 'All recommended files (other files can be generated separate)', value: UniversalChoiceValue.ALL},
{name: 'License', value: UniversalChoiceValue.LICENSE},
{name: 'Changelog', value: UniversalChoiceValue.CHANGELOG},
{name: 'Contributing', value: UniversalChoiceValue.CONTRIBUTING},
{name: 'Code of conduct', value: UniversalChoiceValue.CODE_OF_CONDUCT},
{name: 'Todo', value: UniversalChoiceValue.TODO},
{name: 'Readme', value: UniversalChoiceValue.README},
{name: 'Bug report (issue)', value: GithubChoiceValue.BUG_REPORT},
{name: 'Security vulnerability report', value: GithubChoiceValue.SECURITY},
{name: 'Feature request (issue)', value: GithubChoiceValue.FEATURE_REQUEST},
{name: 'Pull request', value: GithubChoiceValue.PULL_REQUEST},
];
Expand Down
2 changes: 1 addition & 1 deletion src/questions/gitlab-file.question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Answer, UniversalChoiceValue, GitlabChoiceValue, Choice } from '../mode

export async function gitlabFileQuestion(): Promise<Answer> {
const listOfFiles: Choice[] = [
{name: 'All main files (without license, changelog, todo and readme)', value: UniversalChoiceValue.ALL},
{name: 'All recommended files (other files can be generated separate)', value: UniversalChoiceValue.ALL},
{name: 'License', value: UniversalChoiceValue.LICENSE},
{name: 'Changelog', value: UniversalChoiceValue.CHANGELOG},
{name: 'Contributing', value: UniversalChoiceValue.CONTRIBUTING},
Expand Down
1 change: 1 addition & 0 deletions src/templates/github/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './bug-report.template';
export * from './feature-request.template';
export * from './pull-request.template';
export * from './security.template';
40 changes: 40 additions & 0 deletions src/templates/github/security.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { injectable, inject } from 'inversify';
import { DefaultTemplate } from '../default/default.template';
import { FileName } from '../../models/file';

@injectable()
export class Security {
private fileName = FileName.SECURITY;

constructor(@inject('DefaultTemplate') private defaultTemplate: DefaultTemplate) {}

public generateFile(): void {
this.defaultTemplate.generateFile(this.fileName, this.fileContent());
}

private fileContent(): string {
return `# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |
## Reporting a Vulnerability
Use this section to tell people how to report a vulnerability.
Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
`;
}
}

0 comments on commit faa4bf3

Please sign in to comment.