Skip to content

Commit

Permalink
Merge branch 'master' into snyk-upgrade-dcf346b86fe98673beaf7f0834150f9c
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterRao authored Jul 11, 2023
2 parents 41ce776 + d842a6c commit 2422c2c
Show file tree
Hide file tree
Showing 21 changed files with 294 additions and 291 deletions.
31 changes: 19 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@ module.exports = {
extends: ['airbnb', 'eslint-config-ali/typescript'],
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
experimentalObjectRestSpread: true
}
},
env: {
browser: true,
node: true,
es6: true,
mocha: true,
jasmine: true,
jest: true,
jest: true
},
rules: {
indent: ['error', 2],
// override default options
'no-underscore-dangle': [0],
'no-plusplus': [0],
'no-return-await':[0],
'no-return-await': [0],
'no-param-reassign': [0],
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'max-len': [
'warn',
120,
2,
{
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true
}
],
'no-buffer-constructor': [2],
"comma-dangle": [0],
'comma-dangle': [0],
'import/prefer-default-export': [0],
'@typescript-eslint/no-var-requires': [0],
'@typescript-eslint/no-require-imports': [0]
}
};
2 changes: 1 addition & 1 deletion .github/workflows/codeCov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Test Coverage #
name: CodeCov

on:
Expand Down Expand Up @@ -30,4 +31,3 @@ jobs:
npm run tsc
npx nyc --reporter=lcov node_modules/.bin/_mocha -t 120000 -r should test/node/*.test.js test/node/**/*.test.js
npx codecov -t ${{secrets.CODECOV_KEY}}
node test/node/cleanAllBucket.js
85 changes: 36 additions & 49 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
# Code Audit #
name: 'CodeQL'

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master] # The branches below must be a subset of the branches above
schedule:
- cron: '15 7 * * 1'

Expand All @@ -32,42 +21,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: master

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
34 changes: 0 additions & 34 deletions .github/workflows/dev_node_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run test
- run: node test/node/cleanAllBucket.js

node_12:
if: always()
Expand Down Expand Up @@ -106,7 +105,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run test
- run: node test/node/cleanAllBucket.js

node_14:
if: always()
Expand Down Expand Up @@ -140,35 +138,3 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run test
- run: node test/node/cleanAllBucket.js

cleanAllBucket:
if: always()
needs: [node_10, node_12, node_14]
environment: ali_oss_AK
runs-on: ubuntu-latest

env:
ONCI: true
ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}}
ALI_SDK_OSS_SECRET: ${{secrets.ALI_SDK_OSS_SECRET}}
ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}}
ALI_SDK_STS_BUCKET: ${{secrets.ALI_SDK_STS_BUCKET}}
ALI_SDK_STS_ID: ${{secrets.ALI_SDK_STS_ID}}
ALI_SDK_STS_REGION: ${{secrets.ALI_SDK_STS_REGION}}
ALI_SDK_STS_ROLE: ${{secrets.ALI_SDK_STS_ROLE}}
ALI_SDK_STS_SECRET: ${{secrets.ALI_SDK_STS_SECRET}}

strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
with:
ref: develop
- name: clean all bucket
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: node test/node/cleanAllBucket.js
3 changes: 2 additions & 1 deletion .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Regularly clean test buckets at 4:00 every day
name: 'Schdule Delete'

on:
schedule:
- cron: '0 0 * * 1,2,3,4,5,6,0'
- cron: '0 4 1/1 * *'

jobs:
cleanAllBucket:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Vulnerability scanning #
name: SNYK_SCAN
on:
push:
Expand All @@ -11,8 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: master

- run: npm install
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
process.env.CHROME_BIN = require('puppeteer').executablePath();

const isCiEnv = process.env.ONCI;

module.exports = function (config) {
Expand Down
5 changes: 1 addition & 4 deletions lib/browser/managed-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ proto._resumeMultipart = async function _resumeMultipart(checkpoint, options) {

let result;
try {
result = await self._uploadPart(name, uploadId, partNo, data, {
timeout: options.timeout,
disabledMD5: options.disabledMD5
});
result = await self._uploadPart(name, uploadId, partNo, data, options);
} catch (error) {
if (error.status === 404) {
throw self._makeAbortEvent();
Expand Down
34 changes: 19 additions & 15 deletions lib/browser/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,25 @@ proto.listV2 = async function listV2(query, options = {}) {
if (!Array.isArray(objects)) {
objects = [objects];
}
objects = objects.map(obj => ({
name: obj.Key,
url: that._objectUrl(obj.Key),
lastModified: obj.LastModified,
etag: obj.ETag,
type: obj.Type,
size: Number(obj.Size),
storageClass: obj.StorageClass,
owner: obj.Owner
? {
id: obj.Owner.ID,
displayName: obj.Owner.DisplayName
}
: null
}));
objects = objects.map(obj => {
let owner = null;
if (obj.Owner) {
owner = {
id: obj.Owner.ID,
displayName: obj.Owner.DisplayName
};
}
return {
name: obj.Key,
url: that._objectUrl(obj.Key),
lastModified: obj.LastModified,
etag: obj.ETag,
type: obj.Type,
size: Number(obj.Size),
storageClass: obj.StorageClass,
owner
};
});
}
let prefixes = result.data.CommonPrefixes || null;
if (prefixes) {
Expand Down
5 changes: 5 additions & 0 deletions lib/common/multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,19 @@ proto._uploadPart = async function _uploadPart(name, uploadId, partNo, data, opt
options = options || {};
const opt = {};
copy(options).to(opt);
opt.headers = opt.headers || {};
opt.headers = {
...opt.headers,
'Content-Length': data.size
};

// Uploading shards does not require x-oss server side encryption
opt.headers = omit(opt.headers, ['x-oss-server-side-encryption']);
opt.subres = {
partNumber: partNo,
uploadId
};

const params = this._objectRequestParams('PUT', name, opt);
params.mime = opt.mime;
const isBrowserEnv = process && process.browser;
Expand Down
22 changes: 12 additions & 10 deletions lib/common/parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ proto._parallelNode = async function _parallelNode(todo, parallel, fn, sourceDat
let jobs = [];
const tempBatch = todo.length / parallel;
const remainder = todo.length % parallel;
const batch = remainder === 0 ? tempBatch : ((todo.length - remainder) / parallel) + 1;
const batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1;
let taskIndex = 1;
for (let i = 0; i < todo.length; i++) {
if (that.isCancel()) {
Expand All @@ -22,7 +22,7 @@ proto._parallelNode = async function _parallelNode(todo, parallel, fn, sourceDat
jobs.push(fn(that, todo[i]));
}

if (jobs.length === parallel || (taskIndex === batch && i === (todo.length - 1))) {
if (jobs.length === parallel || (taskIndex === batch && i === todo.length - 1)) {
try {
taskIndex += 1;
/* eslint no-await-in-loop: [0] */
Expand All @@ -39,7 +39,7 @@ proto._parallelNode = async function _parallelNode(todo, parallel, fn, sourceDat

proto._parallel = function _parallel(todo, parallel, jobPromise) {
const that = this;
return new Promise((resolve) => {
return new Promise(resolve => {
const _jobErr = [];
if (parallel <= 0 || !todo) {
resolve(_jobErr);
Expand All @@ -59,7 +59,7 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) {
let i = -1;
const len = coll.length;
return function next() {
return (++i < len && !that.isCancel()) ? { value: coll[i], key: i } : null;
return ++i < len && !that.isCancel() ? { value: coll[i], key: i } : null;
};
}

Expand All @@ -68,7 +68,7 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) {
let running = 0;
let looping = false;

function iterateeCallback(err, value) {
function iterateeCallback(err) {
running -= 1;
if (err) {
done = true;
Expand All @@ -88,11 +88,13 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) {
}

function iteratee(value, callback) {
jobPromise(value).then((result) => {
callback(null, result);
}).catch((err) => {
callback(err);
});
jobPromise(value)
.then(result => {
callback(null, result);
})
.catch(err => {
callback(err);
});
}

function replenish() {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/signUtils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const crypto = require('crypto');
const is = require('is-type-of');
const { lowercaseKeyHeader } = require('./utils/lowercaseKeyHeader')
const { lowercaseKeyHeader } = require('./utils/lowercaseKeyHeader');

/**
*
Expand Down
Loading

0 comments on commit 2422c2c

Please sign in to comment.