Skip to content

Commit fe89421

Browse files
committedFeb 6, 2024·
Merge branch 'release/0.3.0'
2 parents 1e61b9a + a675de7 commit fe89421

File tree

22 files changed

+325
-1317
lines changed

22 files changed

+325
-1317
lines changed
 

‎.circleci/config.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ orbs:
33
aws-s3: circleci/aws-s3@3.0.0
44
node: circleci/node@4.7.0
55
sam: circleci/aws-sam-serverless@3.0
6-
aws-cli: circleci/aws-cli@3.1.1 # perform openid connect
6+
aws-cli: circleci/aws-cli@3.1.1 # perform openid connect
77
jobs:
88
build:
99
docker:
@@ -20,7 +20,7 @@ jobs:
2020
- aws-cli/setup:
2121
profile-name: WEB IDENTITY PROFILE
2222
role-arn: $AWS_ROLE_ARN
23-
role-session-name: "CircleCI-${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}"
23+
role-session-name: "CircleCI-${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}"
2424
- checkout
2525
- node/install:
2626
install-yarn: false
@@ -32,9 +32,6 @@ jobs:
3232
- create_zip_upload_to_s3:
3333
lambdaFolder: "edge-lambda-for-s3/deployment"
3434
s3BucketFolder: "edgeLambdaForS3404s"
35-
- create_zip_upload_to_s3:
36-
lambdaFolder: "upsertGitHubTag/deployment"
37-
s3BucketFolder: "upsertGitHubTag"
3835
- create_zip_upload_to_s3:
3936
lambdaFolder: "webhook-testing/deployment"
4037
s3BucketFolder: "webhookTesting"
@@ -62,7 +59,7 @@ jobs:
6259
- aws-cli/setup:
6360
profile-name: WEB IDENTITY PROFILE
6461
role-arn: $AWS_ROLE_ARN
65-
role-session-name: "CircleCI-${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}"
62+
role-session-name: "CircleCI-${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}"
6663
- checkout
6764
- run:
6865
name: Validate index.js

‎.github/PULL_REQUEST_TEMPLATE.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**Description**
2+
A description of the PR, should include a decent explanation as to why this change was needed and a decent explanation as to what this change does
3+
4+
**Issue**
5+
A link to a github issue or SEAB- ticket (using that as a prefix)
6+
7+
**Security**
8+
If there are any concerns that require extra attention from the security team, highlight them here.
9+
10+
Please make sure that you've checked the following before submitting your pull request. Thanks!
11+
12+
- [ ] Ensure that the PR targets the correct branch. Check the milestone or fix version of the ticket.

‎.github/workflows/codeql.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "develop", "master", "hotfix/*", "release/*", "feature/**" ]
6+
pull_request:
7+
branches: [ "develop", "master", "hotfix/*", "release/*" ]
8+
9+
jobs:
10+
analyze:
11+
name: Analyze
12+
runs-on: ubuntu-latest
13+
permissions:
14+
actions: read
15+
contents: read
16+
security-events: write
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
language: [ javascript ]
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v2
29+
with:
30+
languages: ${{ matrix.language }}
31+
queries: +security-and-quality
32+
33+
- name: Autobuild
34+
uses: github/codeql-action/autobuild@v2
35+
36+
- name: Perform CodeQL Analysis
37+
uses: github/codeql-action/analyze@v2
38+
with:
39+
category: "/language:${{ matrix.language }}"

‎.github/workflows/maven.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,12 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install aws-sam-cli
30-
- name: Test with SAM CLI
31-
working-directory: ./upsertGitHubTag
32-
run: |
33-
sam local invoke HelloWorldFunction -e events/event.json -n env.json &> output.txt
34-
grep "Valid push event" output.txt
3530
- name: Test wdl parsing with SAM CLI build and invoke
3631
working-directory: ./wdl-parsing
3732
run: |
3833
sam build --use-container
3934
sam local invoke WDLParsingFunction -e events/event.json &> output.txt
40-
grep "statusCode\":200" output.txt
35+
grep "statusCode\": 200" output.txt
4136
- name: Test Nextflow parsing with SAM CLI build (no invoke)
4237
working-directory: ./nextflow-parsing
4338
# SAM build also runs the Java tests

‎checkUrlExists/lambda/index.js

+50-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
const fs = require("fs");
2-
const tls = require("tls");
1+
const Url = require("url");
2+
const ftp = require("basic-ftp");
3+
const { http, https } = require("follow-redirects");
34

4-
const { curly } = require("node-libcurl");
5-
6-
// important steps to get validation of https (as opposed to http) urls
7-
// Get root certificates so https will work
8-
//
9-
// Write the certificates to a file
10-
// https://stackoverflow.com/questions/63052127/protractor-node-libcurl-failed-ssl-peer-certificate-or-ssh-remote-key-was-not-o
11-
// When doing sam build the file must be in /tmp because other wise it cannot be read
12-
// due to ro file system in container
13-
// https://stackoverflow.com/questions/53810516/getting-error-aws-lambda-erofs-read-only-file-system-open-var-task-assets
14-
const certFilePath = "/tmp/cacert.pem";
15-
// https://nodejs.org/api/tls.html#tls_tls_rootcertificates
16-
// An immutable array of strings representing the root certificates (in PEM format) from the bundled Mozilla CA store as supplied by current Node.js version.
17-
// The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store that is fixed at release time. It is identical on all supported platforms.
18-
const tlsData = tls.rootCertificates.join("\n");
19-
fs.writeFileSync(certFilePath, tlsData);
5+
// The Node url.parse returns an object where the protocol is lower case and contains the colon at the end
6+
const SECURE_FTP_PROTOCOL = "sftp:";
7+
const FTP_PROTOCOL = "ftp:";
8+
const HTTP_PROTOCOL = "http:";
9+
const HTTPS_PROTOCOL = "https:";
2010

2111
/**
2212
* TODO: Change to array of URLs to parse
@@ -50,10 +40,48 @@ async function checkUrl(url) {
5040
}
5141

5242
async function run(url) {
53-
const curlOpts = {
54-
caInfo: certFilePath,
55-
};
56-
return curly.head(url, curlOpts);
43+
const parsedUrl = Url.parse(url);
44+
const protocol = parsedUrl.protocol; // Url.parse() lower cases the protocol
45+
if (FTP_PROTOCOL === protocol || SECURE_FTP_PROTOCOL === protocol) {
46+
const secure = SECURE_FTP_PROTOCOL === protocol;
47+
const ftpClient = new ftp.Client();
48+
try {
49+
let options = {
50+
host: parsedUrl.host,
51+
secure: secure,
52+
...(parsedUrl.port && { port: parsedUrl.port }),
53+
};
54+
await ftpClient.access(options);
55+
const size = await ftpClient.size(parsedUrl.path);
56+
return size > 0
57+
? Promise.resolve()
58+
: Promise.reject("Could not get size for " + url);
59+
} finally {
60+
ftpClient.close();
61+
}
62+
} else if (HTTP_PROTOCOL === protocol) {
63+
return httpOrHttpsRequest(url, http);
64+
} else if (HTTPS_PROTOCOL === protocol) {
65+
return httpOrHttpsRequest(url, https);
66+
}
67+
return Promise.reject("Unsupported protocol: " + protocol);
68+
}
69+
70+
function httpOrHttpsRequest(url, httpOrHttps) {
71+
return new Promise((resolve, reject) => {
72+
const req = httpOrHttps.request(url, {
73+
method: "HEAD",
74+
headers: { "user-agent": "Dockstore/1.0" }, // User-agent must be set for tests to pass, AWS (WAF?) blocks requests with no user-agent
75+
});
76+
req.on("response", (res) => {
77+
if (res.statusCode < 300) {
78+
resolve(res.statusCode);
79+
}
80+
reject(res.statusCode);
81+
});
82+
req.on("error", (err) => reject(err));
83+
req.end();
84+
});
5785
}
5886

5987
function returnResponse(fileFound) {

0 commit comments

Comments
 (0)
Please sign in to comment.