Skip to content

feat: switch dependency to our own package: @casbin/expression-eval 5.2.0 #488

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

Merged
merged 2 commits into from
Oct 28, 2024
Merged
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 package.json
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@
"await-lock": "^2.0.1",
"buffer": "^6.0.3",
"csv-parse": "^5.3.5",
"expression-eval": "^5.0.0",
"@casbin/expression-eval": "^5.2.0",
"minimatch": "^7.4.2"
},
"files": [
2 changes: 1 addition & 1 deletion src/coreEnforcer.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { compile, compileAsync, addBinaryOp } from 'expression-eval';
import { compile, compileAsync, addBinaryOp } from '@casbin/expression-eval';

import { DefaultEffector, Effect, Effector } from './effect';
import { FunctionMap, Model, newModelFromFile, PolicyOp } from './model';
4 changes: 2 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
@@ -179,9 +179,9 @@ function deepCopy(obj: Array<any> | any): any {

function customIn(a: number | string, b: number | string): number {
if ((b as any) instanceof Array) {
return (((b as any) as Array<any>).includes(a) as unknown) as number;
return (b as any as Array<any>).includes(a) as unknown as number;
}
return ((a in (b as any)) as unknown) as number;
return (a in (b as any)) as unknown as number;
}

function bracketCompatible(exp: string): string {
14 changes: 7 additions & 7 deletions test/enforcer.test.ts
Original file line number Diff line number Diff line change
@@ -597,9 +597,9 @@ test('test ABAC multiple eval()', async () => {
);

const e = await newEnforcer(m, policy);
await testEnforce(e, 56, (98 as unknown) as string, 'read', true);
await testEnforce(e, 23, (67 as unknown) as string, 'read', false);
await testEnforce(e, 78, (34 as unknown) as string, 'read', false);
await testEnforce(e, 56, 98 as unknown as string, 'read', true);
await testEnforce(e, 23, 67 as unknown as string, 'read', false);
await testEnforce(e, 78, 34 as unknown as string, 'read', false);
});

// https://github.com/casbin/node-casbin/issues/438
@@ -617,10 +617,10 @@ test('test ABAC single eval() with r. in unexpected places', async () => {
);

const e = await newEnforcer(m, policy);
await testEnforce(e, { id: 3 }, ({ owner: { id: 3 } } as unknown) as string, 'read', true);
await testEnforce(e, {}, ({ owner: {} } as unknown) as string, 'read', false);
await testEnforce(e, { id: 3 }, ({ owner: {} } as unknown) as string, 'read', false);
await testEnforce(e, { id: 3 }, ({ owner: { id: 2 } } as unknown) as string, 'read', false);
await testEnforce(e, { id: 3 }, { owner: { id: 3 } } as unknown as string, 'read', true);
await testEnforce(e, {}, { owner: {} } as unknown as string, 'read', false);
await testEnforce(e, { id: 3 }, { owner: {} } as unknown as string, 'read', false);
await testEnforce(e, { id: 3 }, { owner: { id: 2 } } as unknown as string, 'read', false);
});

test('TestEnforceSync', async () => {
2 changes: 1 addition & 1 deletion test/util.test.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
// limitations under the License.

import { getLogger, logPrint, Util as util } from '../src';
import { compile } from 'expression-eval';
import { compile } from '@casbin/expression-eval';

test('test enableLog success', () => {
getLogger().enableLog(true);
7,353 changes: 4,227 additions & 3,126 deletions yarn.lock

Large diffs are not rendered by default.