Skip to content

Commit

Permalink
Merge pull request #6024 from witness-me/wfs-invalid-json
Browse files Browse the repository at this point in the history
feat(stepfunctions): Prevent launching Workflow Studio with invalid JSON + save metric refactoring
  • Loading branch information
justinmk3 authored Dec 19, 2024
2 parents f48080f + 1701d49 commit 901bfbe
Show file tree
Hide file tree
Showing 919 changed files with 82,512 additions and 23,695 deletions.
42 changes: 34 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
mocha: true,
es2024: true,
},
plugins: ['@typescript-eslint', 'unicorn', 'header', 'security-node', 'aws-toolkits'],
plugins: ['@typescript-eslint', '@stylistic', 'unicorn', 'header', 'security-node', 'aws-toolkits'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand Down Expand Up @@ -113,6 +113,20 @@ module.exports = {
'no-constant-condition': ['error', { checkLoops: false }],
'no-empty': 'off',

// https://eslint.style/rules/default/spaced-comment
// Require space after // comment.
'@stylistic/spaced-comment': [
'error',
'always',
{
block: {
markers: ['!'], // Allow the /*!…*/ license header.
// exceptions: ['*'],
// balanced: true
},
},
],

// Rules from https://github.com/sindresorhus/eslint-plugin-unicorn
// TODO: 'unicorn/no-useless-promise-resolve-reject': 'error',
// TODO: 'unicorn/prefer-at': 'error',
Expand Down Expand Up @@ -162,7 +176,8 @@ module.exports = {
'aws-toolkits/no-incorrect-once-usage': 'error',
'aws-toolkits/no-string-exec-for-child-process': 'error',
'aws-toolkits/no-console-log': 'error',

'aws-toolkits/no-json-stringify-in-log': 'error',
'aws-toolkits/no-printf-mismatch': 'error',
'no-restricted-imports': [
'error',
{
Expand All @@ -173,13 +188,24 @@ module.exports = {
"Avoid importing from the core lib's dist/ folders; please use directly from the core lib defined exports.",
},
],
// The following will place an error on the `fs-extra` import since we do not want it to be used for browser compatibility reasons.
paths: [
{
name: 'fs-extra',
message:
'Avoid fs-extra, use shared/fs/fs.ts. Notify the Toolkit team if your required functionality is not available.',
},
{
name: 'fs',
message: 'Avoid node:fs and use shared/fs/fs.ts when possible.',
},
{
name: 'child_process',
message:
'Avoid child_process, use ChildProcess from `shared/utilities/processUtils.ts` instead.',
},
],
},
// The following will place an error on the `fs-extra` import since we do not want it to be used for browser compatibility reasons.
// {
// name: 'fs-extra',
// message:
// 'Avoid fs-extra, use shared/fs/fs.ts. Notify the Toolkit team if your required functionality is not available.',
// },
],
},
}
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* @aws/aws-ides-team
packages/core/src/codewhisperer/ @aws/codewhisperer-team
packages/core/src/amazonqFeatureDev/ @aws/earlybird
packages/core/src/codewhispererChat/ @aws/dexp
packages/core/src/amazonq/ @aws/dexp
packages/core/src/codewhispererChat/ @aws/flare
packages/core/src/amazonq/ @aws/flare
packages/core/src/awsService/accessanalyzer/ @aws/access-analyzer
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/unreliable_test_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: unreliable test
about: Help us monitor our test suite by reporting flaky tests.
labels: tests-ci-cd
---

## Test Details

- Name of test:
- OS of failure:
- VSCode version of failure (minimum/insider/stable):
- Link to failing run:
- Link to failing test:

## Log of Test Failure

## Additional Information
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

---

<!--- REMINDER: Ensure that your PR meets the guidelines in CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time.
- Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
9 changes: 9 additions & 0 deletions .github/workflows/jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"pattern": "packages/**/*.ts",
"ignore": ["**node_modules**", "**dist**", "**/scripts/**"],
"gitignore": true,
"threshold": 3.0,
"minLines": 10,
"output": "./",
"reporters": ["json"]
}
67 changes: 67 additions & 0 deletions .github/workflows/lintbranch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Check that branch name conforms to GitHub naming convention:
// https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names#naming-branches-and-tags

// To run self-tests,
// node lintbranch.js test
// TODO: deduplicate code from lintbranch.js and lintcommit.js.

function isValid(branchName) {
const branchNameRegex = /^[a-zA-Z][a-zA-Z0-9._/-]*$/

return branchNameRegex.test(branchName)
}

function run(branchName) {
if (isValid(branchName)) {
console.log(`Branch name "${branchName}" is valid.`)
process.exit(0)
} else {
const helpUrl =
'https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names#naming-branches-and-tags'
console.log(`Branch name "${branchName}" is invalid see ${helpUrl} for more information.`)
process.exit(1)
}
}

function _test() {
const tests = {
'feature/branch-name': true,
feature_123: true,
'my-branch': true,
'123invalid-start': false,
'!invalid@start': false,
'': false,
'another/valid-name134': true,
'feature/123";id;{echo,Y2F0IC9ldGMvcGFzc3dk}|{base64,-d}|{bash,-i};#': false,
}

let passed = 0
let failed = 0

for (const [branchName, expected] of Object.entries(tests)) {
const result = isValid(branchName)
if (result === expected) {
console.log(`✅ Test passed for "${branchName}"`)
passed++
} else {
console.log(`❌ Test failed for "${branchName}" (expected "${expected}", got "${result}")`)
failed++
}
}

console.log(`\n${passed} tests passed, ${failed} tests failed`)
}

function main() {
const mode = process.argv[2]

if (mode === 'test') {
_test()
} else if (mode === 'run') {
run(process.argv[3])
} else {
throw new Error(`Unknown mode: ${mode}`)
}
}

main()
1 change: 1 addition & 0 deletions .github/workflows/lintcommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Invalid pull request title: \`${title}\`
* scope: lowercase, <30 chars
* subject: must be <100 chars
* documentation: https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title
* Hint: *close and re-open the PR* to re-trigger CI (after fixing the PR title).
`
: `Pull request title matches the [expected format](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title).`

Expand Down
Loading

0 comments on commit 901bfbe

Please sign in to comment.