Skip to content
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

Update CodeQL scanning to separate workflow and fix issues #7005

Merged
merged 12 commits into from
Jul 18, 2024
65 changes: 65 additions & 0 deletions .github/workflows/ci-validate-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Validate CodeQL

on:
workflow_dispatch:
push:
branches:
- master

pull_request:
branches:
- master

schedule:
- cron: 0 7 * * 3

permissions:
security-events: write

jobs:
cross-platform_cross-browser:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]

env:
PLAYWRIGHT_BROWSERS_PATH: 0

steps:
- name: Set git to use LF
if: ${{ matrix.os == 'windows-latest' }}
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- name: Checkout Branch
uses: actions/checkout@v2

- if: ${{ github.event_name == 'pull_request' }}
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master

- name: Cache multiple paths
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:javascript-typescript"
12 changes: 1 addition & 11 deletions .github/workflows/ci-validate-platforms.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Validate Platforms/Browsers

on:
workflow_dispatch:
push:
branches:
- master
Expand Down Expand Up @@ -64,15 +65,4 @@ jobs:
npx playwright install
- name: Run tests in all Packages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: npm run test

- name: Initialize CodeQL
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: github/codeql-action/init@v1
with:
languages: javascript, typescript

- name: Perform CodeQL Analysis
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: github/codeql-action/analyze@v1
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"comment": "Adds support for FASTElement hydration",
"packageName": "@microsoft/fast-element",
"email": "171390049+prabhujayapal@users.noreply.github.com",
"dependentChangeType": "patch"
"dependentChangeType": "prerelease"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix CodeQL issues",
"packageName": "@microsoft/fast-element",
"email": "7559015+janechu@users.noreply.github.com",
"dependentChangeType": "prerelease"
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix CodeQL issues",
"packageName": "@microsoft/fast-router",
"email": "7559015+janechu@users.noreply.github.com",
"dependentChangeType": "prerelease"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"comment": "Adds support for FASTElement hydration",
"packageName": "@microsoft/fast-ssr",
"email": "171390049+prabhujayapal@users.noreply.github.com",
"dependentChangeType": "patch"
"dependentChangeType": "prerelease"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const bindingStartMarker = /fe-b\$\$start\$\$(\d+)\$\$(.+)\$\$fe-b/;
const bindingEndMarker = /fe-b\$\$end\$\$(\d+)\$\$(.+)\$\$fe-b/;
const repeatViewStartMarker = /fe-repeat\$\$start\$\$(\d+)\$\$fe-repeat/;
const repeatViewEndMarker = /fe-repeat\$\$end\$\$(\d+)\$\$fe-repeat/;
const elementBoundaryStartMarker = /fe-eb\$\$start\$\$(.+)\$\$fe-eb/;
const elementBoundaryEndMarker = /fe-eb\$\$end\$\$(.+)\$\$fe-eb/;
const elementBoundaryStartMarker = /^(?:.{0,1000})fe-eb\$\$start\$\$(.+?)\$\$fe-eb/;
const elementBoundaryEndMarker = /fe-eb\$\$end\$\$(.{0,1000})\$\$fe-eb(?:.{0,1000})$/;

function isComment(node: Node): node is Comment {
return node && node.nodeType === Node.COMMENT_NODE;
Expand Down Expand Up @@ -54,7 +54,7 @@ export const HydrationMarkup = Object.freeze({
return repeatViewEndMarker.test(content);
},
isElementBoundaryStartMarker(node: Node) {
return isComment(node) && elementBoundaryStartMarker.test(node.data);
return isComment(node) && elementBoundaryStartMarker.test(node.data.trim());
},
isElementBoundaryEndMarker(node: Node) {
return isComment(node) && elementBoundaryEndMarker.test(node.data);
Expand Down Expand Up @@ -93,7 +93,7 @@ export const HydrationMarkup = Object.freeze({
* Parses element Id from element boundary markers
*/
parseElementBoundaryStartMarker(content: string): null | string {
return parseStringMarker(elementBoundaryStartMarker, content);
return parseStringMarker(elementBoundaryStartMarker, content.trim());
},
parseElementBoundaryEndMarker(content: string): null | string {
return parseStringMarker(elementBoundaryEndMarker, content);
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/fast-element/src/dom-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function safeURL(
): DOMSink {
return (target: Node, name: string, value: string, ...rest: any[]) => {
if (isString(value)) {
value = value.replace("javascript:", "");
value = value.replace(/(javascript:|vbscript:|data:)/, "");
}

sink(target, name, value, ...rest);
Expand Down
23 changes: 14 additions & 9 deletions packages/web-components/fast-router/src/query-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const encode = encodeURIComponent;
const encodeKey = (key: string) => encode(key).replace("%24", "$");
const encodeKey = (key: string) => encode(key).replace(/%24/g, "$");

function buildParam(key: string, value: any, traditional?: boolean): Array<string> {
let result: string[] = [];
Expand Down Expand Up @@ -51,8 +51,12 @@ function processScalarParam(existedParam: any, value: string): any {
return value;
}

function parseComplexParam(queryParams: Object, keys: string[], value: any): void {
let currentParams: any = queryParams;
function parseComplexParam(
queryParams: Record<string, any>,
keys: string[],
value: any
): void {
let currentParams: Record<string, any> = queryParams;
const keysLastIndex = keys.length - 1;

for (let j = 0; j <= keysLastIndex; j++) {
Expand All @@ -61,13 +65,14 @@ function parseComplexParam(queryParams: Object, keys: string[], value: any): voi
// The value has to be an array or a false value
// It can happen that the value is no array if the key was repeated with traditional style like `list=1&list[]=2`
const prevValue =
!currentParams[key] || typeof currentParams[key] === "object"
? currentParams[key]
: [currentParams[key]];
currentParams = currentParams[key] =
prevValue || (isNaN(keys[j + 1] as any) ? {} : []);
!currentParams.get(key) || typeof currentParams.get(key) === "object"
? currentParams.get(key)
: [currentParams.get(key)];
currentParams.set(key, prevValue || (isNaN(keys[j + 1] as any) ? {} : []));
currentParams = currentParams.get(key);
} else {
currentParams = currentParams[key] = value;
currentParams.set(key, value);
currentParams = currentParams.get(key);
}
}
}
Expand Down
Loading