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

Upgraded uuid to a newer version #2217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Blob:
- Fixed startCopyFromURL, copyFromURL API to return 400 (InvalidHeaderValue) when copy source has invalid format. (issue #1954)
- Fixed CommitBlockList API to return 400 (InvalidXmlDocument) when the request is sent with JSON body. (issue #1955)
- Added "x-ms-is-hns-enabled" header in x-ms-is-hns-enabled API responds (issue #1810)
- Upgraded uuid to a newer version.

Queue:

Expand Down
91 changes: 67 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"to-readable-stream": "^2.1.0",
"tslib": "^2.3.0",
"uri-templates": "^0.2.0",
"uuid": "^3.3.2",
"uuid": "^9.0.0",
"winston": "^3.1.0",
"xml2js": "^0.6.0"
},
Expand All @@ -65,7 +65,7 @@
"@types/rimraf": "^3.0.0",
"@types/stoppable": "^1.1.1",
"@types/uri-templates": "^0.1.29",
"@types/uuid": "^3.4.4",
"@types/uuid": "^9.0.0",
"@types/validator": "^13.1.4",
"@types/vscode": "^1.39.0",
"@types/xml2js": "^0.4.3",
Expand Down
6 changes: 3 additions & 3 deletions src/blob/lease/LeaseAvailableState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid = require("uuid");
import { v4 as uuidv4 } from 'uuid';

import StorageErrorFactory from "../errors/StorageErrorFactory";
import {
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class LeaseAvailableState extends LeaseStateBase {
if (duration === -1) {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Infinite,
Expand All @@ -119,7 +119,7 @@ export default class LeaseAvailableState extends LeaseStateBase {
} else {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Fixed,
Expand Down
6 changes: 3 additions & 3 deletions src/blob/lease/LeaseBrokenState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid = require("uuid");
import { v4 as uuidv4 } from 'uuid';

import StorageErrorFactory from "../errors/StorageErrorFactory";
import {
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class LeaseBrokenState extends LeaseStateBase {
if (duration === -1) {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Infinite,
Expand All @@ -159,7 +159,7 @@ export default class LeaseBrokenState extends LeaseStateBase {
} else {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Fixed,
Expand Down
8 changes: 4 additions & 4 deletions src/blob/lease/LeaseExpiredState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid = require("uuid");
import { v4 as uuidv4 } from 'uuid';

import StorageErrorFactory from "../errors/StorageErrorFactory";
import {
Expand Down Expand Up @@ -153,7 +153,7 @@ export default class LeaseExpiredState extends LeaseStateBase {
if (duration === -1) {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Infinite,
Expand All @@ -166,7 +166,7 @@ export default class LeaseExpiredState extends LeaseStateBase {
} else {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Fixed,
Expand Down Expand Up @@ -206,7 +206,7 @@ export default class LeaseExpiredState extends LeaseStateBase {
leaseDurationSeconds: this.lease.leaseDurationSeconds,
leaseExpireTime: new Date(
this.context.startTime!.getTime() +
this.lease.leaseDurationSeconds! * 1000
this.lease.leaseDurationSeconds! * 1000
),
leaseBreakTime: undefined
},
Expand Down
8 changes: 4 additions & 4 deletions src/blob/lease/LeaseLeasedState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid = require("uuid");
import { v4 as uuidv4 } from 'uuid';

import { minDate } from "../../common/utils/utils";
import StorageErrorFactory from "../errors/StorageErrorFactory";
Expand Down Expand Up @@ -100,7 +100,7 @@ export default class LeaseLeasedState extends LeaseStateBase {
if (duration === -1) {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Infinite,
Expand All @@ -113,7 +113,7 @@ export default class LeaseLeasedState extends LeaseStateBase {
} else {
return new LeaseLeasedState(
{
leaseId: proposedLeaseId || uuid(),
leaseId: proposedLeaseId || uuidv4(),
leaseState: LeaseStateType.Leased,
leaseStatus: LeaseStatusType.Locked,
leaseDurationType: LeaseDurationType.Fixed,
Expand Down Expand Up @@ -240,7 +240,7 @@ export default class LeaseLeasedState extends LeaseStateBase {
leaseDurationSeconds: this.lease.leaseDurationSeconds,
leaseExpireTime: new Date(
this.context.startTime!.getTime() +
this.lease.leaseDurationSeconds! * 1000
this.lease.leaseDurationSeconds! * 1000
),
leaseBreakTime: undefined
},
Expand Down
24 changes: 11 additions & 13 deletions src/blob/middlewares/blobStorageContext.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextFunction, Request, RequestHandler, Response } from "express";
import uuid from "uuid/v4";
import { v4 as uuidv4 } from 'uuid';

import logger from "../../common/Logger";
import { IP_REGEX } from "../../common/utils/constants";
Expand Down Expand Up @@ -54,7 +54,7 @@ export function internnalBlobStorageContextMiddleware(
): void {
// Set server header in every Azurite response
res.setHeader(HeaderConstants.SERVER, `Azurite-Blob/${VERSION}`);
const requestID = uuid();
const requestID = uuidv4();

if (!skipApiVersionCheck) {
const apiVersion = req.getHeader(HeaderConstants.X_MS_VERSION);
Expand Down Expand Up @@ -149,7 +149,7 @@ export function blobStorageContextMiddleware(
): void {
// Set server header in every Azurite response
res.setHeader(HeaderConstants.SERVER, `Azurite-Blob/${VERSION}`);
const requestID = uuid();
const requestID = uuidv4();

if (!skipApiVersionCheck) {
const apiVersion = req.header(HeaderConstants.X_MS_VERSION);
Expand All @@ -166,12 +166,10 @@ export function blobStorageContextMiddleware(
blobContext.xMsRequestID = requestID;

logger.info(
`BlobStorageContextMiddleware: RequestMethod=${req.method} RequestURL=${
req.protocol
`BlobStorageContextMiddleware: RequestMethod=${req.method} RequestURL=${req.protocol
}://${req.hostname}${req.url} RequestHeaders:${JSON.stringify(
req.headers
)} ClientIP=${req.ip} Protocol=${req.protocol} HTTPVersion=${
req.httpVersion
)} ClientIP=${req.ip} Protocol=${req.protocol} HTTPVersion=${req.httpVersion
}`,
requestID
);
Expand Down Expand Up @@ -242,11 +240,11 @@ export function extractStoragePartsFromPath(
path: string,
disableProductStyleUrl?: boolean,
): [
string | undefined,
string | undefined,
string | undefined,
boolean | undefined
] {
string | undefined,
string | undefined,
string | undefined,
boolean | undefined
] {
let account;
let container;
let blob;
Expand All @@ -265,7 +263,7 @@ export function extractStoragePartsFromPath(
const firstDotIndex = hostname.indexOf(".");
// If hostname is not an IP address or a known host name, and has a dot inside,
// we assume user wants to access emulator with a production-like URL.
if (!disableProductStyleUrl &&!isIPAddress && !isNoAccountHostName && firstDotIndex > 0) {
if (!disableProductStyleUrl && !isIPAddress && !isNoAccountHostName && firstDotIndex > 0) {
account = hostname.substring(
0,
firstDotIndex
Expand Down
Loading