Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Tvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Tvm {
* @private
*/
async _validateOWCreds (apihost, namespace, auth) {
const ow = openwhisk({ api_key: auth, apihost: apihost })
const ow = openwhisk({ api_key: auth, apihost })

// 1. Check if ow credientials are valid by retrieving the namespace list
// attached to owAuth
Expand Down
2 changes: 1 addition & 1 deletion lib/impl/AzureBlobTvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AzureBlobTvm extends Tvm {
permissions.add = permissions.read = permissions.create = permissions.delete = permissions.write = permissions.list = true
const commonSasParams = {
permissions: permissions.toString(),
expiryTime: expiryTime
expiryTime
}

const sasQueryParamsPrivate = azure.generateBlobSASQueryParameters({ ...commonSasParams, containerName: privateContainerName }, sharedKeyCredential)
Expand Down
8 changes: 5 additions & 3 deletions lib/impl/AzurePresignTvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class AzurePresignTvm extends Tvm {

// limit expiry between 2 seconds and 24 hours
this._addToValidationSchema('expiryInSeconds', joi.number().integer().min(2).max(24 * 60 * 60).required())
// eslint-disable-next-line prefer-regex-literals
const limitLength = new RegExp('^.{1,3}$') // limit length from 1-3
// eslint-disable-next-line prefer-regex-literals
const limitChars = new RegExp('^[rwd]*$') // only allow combination of 'r', 'w' or 'd'
this._addToValidationSchema('permissions', joi.string().regex(limitLength).regex(limitChars).optional())
}
Expand All @@ -60,13 +62,13 @@ class AzurePresignTvm extends Tvm {

const commonSasParams = {
permissions: permissions.toString(),
expiryTime: expiryTime,
expiryTime,
blobName: params.blobName,
identifier: identifier,
identifier,
version: '2019-12-12'
}

const sasQueryParamsPrivate = azure.generateBlobSASQueryParameters({ ...commonSasParams, containerName: containerName }, sharedKeyCredential)
const sasQueryParamsPrivate = azure.generateBlobSASQueryParameters({ ...commonSasParams, containerName }, sharedKeyCredential)
return {
signature: sasQueryParamsPrivate.toString()
}
Expand Down
16 changes: 8 additions & 8 deletions lib/impl/AzureUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const azure = require('@azure/storage-blob')
*/
function _signRequest (method, resource, date, storageAccessKey) {
const canonicalHeaders = 'x-ms-date:' + date + '\n' + 'x-ms-version:2019-02-02'
var stringToSign = method + '\n\n\n\n\n\n\n\n\n\n\n\n' + canonicalHeaders + '\n' + resource
const stringToSign = method + '\n\n\n\n\n\n\n\n\n\n\n\n' + canonicalHeaders + '\n' + resource
return Crypto.createHmac('sha256', Buffer.from(storageAccessKey, 'base64')).update(stringToSign, 'utf8').digest('base64')
}

Expand All @@ -42,8 +42,8 @@ function _signRequest (method, resource, date, storageAccessKey) {
*/
async function getAccessPolicy (containerURL, storageAccount, storageAccessKey) {
// use API call as this._azure.containerURLPrivate.getAccessPolicy calls fails for policy with empty permissions
var index = containerURL.url.lastIndexOf('/')
var containerName = containerURL.url.substring(index + 1, containerURL.url.length)
const index = containerURL.url.lastIndexOf('/')
const containerName = containerURL.url.substring(index + 1, containerURL.url.length)

const resource = '/' + storageAccount + '/' + containerName + '\ncomp:acl\nrestype:container'
const date = new Date().toUTCString()
Expand Down Expand Up @@ -84,7 +84,7 @@ async function getAccessPolicy (containerURL, storageAccount, storageAccessKey)
async function setAccessPolicy (containerURL) {
const id = uuidv4()
// set access policy with new id and without any permissions
await containerURL.setAccessPolicy(azure.Aborter.none, undefined, [{ id: id, accessPolicy: { permission: '' } }])
await containerURL.setAccessPolicy(azure.Aborter.none, undefined, [{ id, accessPolicy: { permission: '' } }])
}

/**
Expand Down Expand Up @@ -117,8 +117,8 @@ function getContainerURL (accountURL, sharedKeyCredential, containerName) {
}

module.exports = {
getAccessPolicy: getAccessPolicy,
setAccessPolicy: setAccessPolicy,
addAccessPolicyIfNotExists: addAccessPolicyIfNotExists,
getContainerURL: getContainerURL
getAccessPolicy,
setAccessPolicy,
addAccessPolicyIfNotExists,
getContainerURL
}
Loading