Skip to content

Commit b699578

Browse files
Rob DeRosaRob DeRosa
authored andcommitted
initial commit
0 parents  commit b699578

25 files changed

+19950
-0
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"plugins": ["jest", "@typescript-eslint"],
3+
"extends": ["plugin:github/recommended"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 9,
7+
"sourceType": "module",
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"eslint-comments/no-use": "off",
12+
"import/no-namespace": "off",
13+
"no-unused-vars": "off",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
16+
"@typescript-eslint/no-require-imports": "error",
17+
"@typescript-eslint/array-type": "error",
18+
"@typescript-eslint/await-thenable": "error",
19+
"@typescript-eslint/ban-ts-comment": "error",
20+
"camelcase": "off",
21+
"@typescript-eslint/consistent-type-assertions": "error",
22+
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
23+
"@typescript-eslint/func-call-spacing": ["error", "never"],
24+
"@typescript-eslint/no-array-constructor": "error",
25+
"@typescript-eslint/no-empty-interface": "error",
26+
"@typescript-eslint/no-explicit-any": "error",
27+
"@typescript-eslint/no-extraneous-class": "error",
28+
"@typescript-eslint/no-for-in-array": "error",
29+
"@typescript-eslint/no-inferrable-types": "error",
30+
"@typescript-eslint/no-misused-new": "error",
31+
"@typescript-eslint/no-namespace": "error",
32+
"@typescript-eslint/no-non-null-assertion": "warn",
33+
"@typescript-eslint/no-unnecessary-qualifier": "error",
34+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
35+
"@typescript-eslint/no-useless-constructor": "error",
36+
"@typescript-eslint/no-var-requires": "error",
37+
"@typescript-eslint/prefer-for-of": "warn",
38+
"@typescript-eslint/prefer-function-type": "warn",
39+
"@typescript-eslint/prefer-includes": "error",
40+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
41+
"@typescript-eslint/promise-function-async": "error",
42+
"@typescript-eslint/require-array-sort-compare": "error",
43+
"@typescript-eslint/restrict-plus-operands": "error",
44+
"semi": "off",
45+
"@typescript-eslint/semi": ["error", "never"],
46+
"@typescript-eslint/type-annotation-spacing": "error",
47+
"@typescript-eslint/unbound-method": "error"
48+
},
49+
"env": {
50+
"node": true,
51+
"es6": true,
52+
"jest/globals": true
53+
}
54+
}

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: 'npm'
5+
# Look for `package.json` and `lock` files in the `root` directory
6+
directory: '/'
7+
# Check the npm registry for updates every day (weekdays)
8+
schedule:
9+
interval: 'daily'

.github/workflows/detect-pii.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'pii-detection'
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
- edited
7+
issue_comment:
8+
types:
9+
- created
10+
- edited
11+
pull_request:
12+
types:
13+
- opened
14+
- edited
15+
pull_request_review_comment:
16+
types:
17+
- created
18+
- edited
19+
jobs:
20+
detect-pii:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: ./
25+
name: "run PII detector"
26+
with:
27+
azure-cognitive-subscription-key: ${{ secrets.AZURE_COGNITIVE_SUBSCRIPTION_KEY }}
28+
azure-cognitive-endpoint: ${{ secrets.AZURE_COGNITIVE_ENDPOINT }}
29+
categories: "email|ip|phone number"
30+
label-text: "PII DETECTED!!"
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module.exports = async (gh) => {
2+
3+
let violations = gh.core.getInput("violations", {});
4+
5+
if (!violations || violations.length == 0) {
6+
console.log("No violations detected.")
7+
return;
8+
}
9+
10+
let packages = JSON.parse(violations);
11+
let bodyMessage = "## :package: Package Policy Violation\n\n" +
12+
`Commit: ${gh.context.sha}\n\n` +
13+
"The following referenced package(s) violate the package policy put in place by the administrator of this repository:\n";
14+
15+
packages.forEach((item) => {
16+
bodyMessage += `\n- [ ] :x: ${item.name} - ${item.version}`;
17+
});
18+
bodyMessage += "\n\nPlease choose alternate packages that conform to the package policy and re-attempt."
19+
20+
if (gh.context.eventName == "push") {
21+
let issue = await gh.github.issues.create({
22+
owner: gh.context.repo.owner,
23+
repo: gh.context.repo.repo,
24+
title: "Package Violation Detected!!",
25+
assignee: gh.context.payload.pusher.name,
26+
body: bodyMessage,
27+
labels: ["Package Violation"],
28+
});
29+
30+
console.log(`Issue created - ${issue.data.number} - ${issue.data.html_url}`);
31+
} else {
32+
33+
await gh.github.issues.addLabels({
34+
labels: ["Package Violation"],
35+
owner: gh.context.repo.owner,
36+
repo: gh.context.repo.repo,
37+
issue_number: gh.context.payload.pull_request.number
38+
})
39+
40+
let issue = await gh.github.issues.createComment({
41+
owner: gh.context.repo.owner,
42+
repo: gh.context.repo.repo,
43+
issue_number: gh.context.payload.pull_request.number,
44+
body: bodyMessage
45+
})
46+
47+
console.log(`Pull request labeled and commented - ${issue.data.number} - ${issue.data.html_url}`);
48+
}
49+
50+
gh.core.setFailed("!!! PACKAGE POLICY VIOLATIONS DETECTED !!!");
51+
}

.github/workflows/pp-test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Enforce Package Policy"
2+
on:
3+
push:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
jobs:
9+
enforce-package-policy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: rob-derosa/package-policy@v1
14+
name: "Check for package violations"
15+
id: package-policy
16+
with:
17+
policy: allow
18+
policy-url: "https://gist.githubusercontent.com/rob-derosa/965f4d51e5eb006a928cffe176998923/raw/1293e1273e66dfa8574ea3579261d95fc4670373/policy.json"
19+
fail-if-violations: false
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
- uses: actions/github-script@v2
22+
name: "Respond to package violations"
23+
id: post-script
24+
with:
25+
github-token: ${{secrets.GITHUB_TOKEN}}
26+
violations: ${{steps.package-policy.outputs.violations}}
27+
script: |
28+
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/package_violation.js`)
29+
await script({github, context, core})

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid"
10+
}

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"program": "${workspaceFolder}/lib/main.js"
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)