Skip to content

Latest commit

 

History

History
416 lines (382 loc) · 10.3 KB

cred-class-field-type-options-password-missing.md

File metadata and controls

416 lines (382 loc) · 10.3 KB

cred-class-field-type-options-password-missing

In a sensitive string-type field, typeOptions.password must be set to true to obscure the input. A field name is sensitive if it contains the strings: secret,password,token,key. See exceptions in source.

📋 This rule is part of the plugin:n8n-nodes-base/credentials config.

🔧 Run ESLint with --fix option to autofix the issue flagged by this rule.

Examples

❌ Example of incorrect code:

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'secret',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'password',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'token',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'key',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'appPassword',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'clientSecret',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'accessToken',
            type: 'string',
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'secret',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'password',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'token',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'key',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'appPassword',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'clientSecret',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'test';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'accessToken',
            type: 'string',
            typeOptions: { someOption: true },
            default: '',
            required: true,
        },
    ];
}

✅ Example of correct code:

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'secret',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'password',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'token',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'key',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'appPassword',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'clientSecret',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'accessToken',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'accessKeyId',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: 'passwordless',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Some Display Name',
            name: '/token',
            type: 'string',
            typeOptions: { password: true },
            default: '',
            required: true,
        },
    ];
}

export class TestApi implements ICredentialType {
    name = 'testApi';
    displayName = 'Test API';
    documentationUrl = 'zammad';
    properties: INodeProperties[] = [
        {
            displayName: 'Access Token',
            name: 'accessToken',
            type: 'hidden',
            default: '',
            required: true,
        },
    ];
}

Links