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
4 changes: 4 additions & 0 deletions sdk/storage/storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- Added support for encryption scopes.
- Added support for encryption scope SAS.

### Bugs Fixed

- Correted permission string parsing in DataLakePathClient.setPermissions() and DataLakePathClient.getAccessControl().

## 12.10.0 (2022-07-08)

### Features Added
Expand Down

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

35 changes: 18 additions & 17 deletions sdk/storage/storage-file-datalake/src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ export function toPathGetAccessControlResponse(
};
}

export function toRolePermissions(
permissionsString: string,
allowStickyBit: boolean = false
): RolePermissions {
export function toRolePermissions(permissionsString: string): RolePermissions {
const error = new RangeError(
`toRolePermissions() Invalid role permissions string ${permissionsString}`
);
Expand All @@ -243,12 +240,6 @@ export function toRolePermissions(
let execute = false;
if (permissionsString[2] === "x") {
execute = true;
} else if (allowStickyBit) {
if (permissionsString[2] === "t") {
execute = true;
} else if (permissionsString[2] !== "-") {
throw error;
}
} else if (permissionsString[2] !== "-") {
throw error;
}
Expand All @@ -265,14 +256,22 @@ export function toPermissions(permissionsString?: string): PathPermissions | und
throw RangeError(`toPermissions() Invalid permissions string ${permissionsString}`);
}

// Case insensitive
permissionsString = permissionsString.toLowerCase();

let stickyBit = false;
if (permissionsString[8] === "t") {
stickyBit = true;
const firstPart = permissionsString.substr(0, 8);
const lastPart = permissionsString.substr(9);
permissionsString = firstPart + "x" + lastPart;
} else if (permissionsString[8] === "T") {
stickyBit = true;
const firstPart = permissionsString.substr(0, 8);
const lastPart = permissionsString.substr(9);
permissionsString = firstPart + "-" + lastPart;
}

// Case insensitive
permissionsString = permissionsString.toLowerCase();

let extendedAcls = false;
if (permissionsString.length === 10) {
if (permissionsString[9] === "+") {
Expand All @@ -284,9 +283,9 @@ export function toPermissions(permissionsString?: string): PathPermissions | und
}
}

const owner = toRolePermissions(permissionsString.substr(0, 3), false);
const group = toRolePermissions(permissionsString.substr(3, 3), false);
const other = toRolePermissions(permissionsString.substr(6, 3), true);
const owner = toRolePermissions(permissionsString.substr(0, 3));
const group = toRolePermissions(permissionsString.substr(3, 3));
const other = toRolePermissions(permissionsString.substr(6, 3));

return {
owner,
Expand Down Expand Up @@ -432,7 +431,9 @@ export function toAclString(acl: PathAccessControlItem[]): string {
}

export function toRolePermissionsString(p: RolePermissions, stickyBit: boolean = false): string {
return `${p.read ? "r" : "-"}${p.write ? "w" : "-"}${stickyBit ? "t" : p.execute ? "x" : "-"}`;
return `${p.read ? "r" : "-"}${p.write ? "w" : "-"}${
stickyBit ? (p.execute ? "t" : "T") : p.execute ? "x" : "-"
}`;
}

export function toPermissionsString(permissions: PathPermissions): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ describe("DataLakePathClient Node.js only", () => {
permissions: {
read: false,
write: true,
execute: true,
execute: false,
},
},
];
Expand Down Expand Up @@ -571,10 +571,7 @@ describe("DataLakePathClient Node.js only", () => {

assert.deepStrictEqual(response.owner, "$superuser");
assert.deepStrictEqual(response.group, "$superuser");
assert.deepStrictEqual(response.permissions, {
...permissions,
other: { ...permissions.other, execute: true },
});
assert.deepStrictEqual(response.permissions, permissions);
assert.deepStrictEqual(response.acl, acl);
});

Expand Down Expand Up @@ -628,7 +625,7 @@ describe("DataLakePathClient Node.js only", () => {
other: {
read: false,
write: true,
execute: false,
execute: true,
},
};

Expand Down
Loading