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

Add: Kerberos to Credential and Target #4335

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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 allowedSnakeCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
'is_task_event',
'key_code',
'known_nvt_count',
'krb5_credential',

Check warning on line 292 in allowedSnakeCase.js

View check run for this annotation

Codecov / codecov/patch

allowedSnakeCase.js#L292

Added line #L292 was not covered by tests
'last_id',
'last_report',
'last_seen',
Expand Down
8 changes: 7 additions & 1 deletion public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"Close": "Schließen",
"Closed": "Geschlossen",
"Closed CVEs": "Geschlossene CVEs",
"Comma separated list of KDCs": "Komma-separierte Liste von KDCs",
"Comment": "Kommentar",
"Community": "Community",
"Complete": "Vollständig",
Expand Down Expand Up @@ -432,6 +433,7 @@
"Create new {{entity}}": "{{entity}} erstellen",
"Create new Container Task": "Neue Container-Aufgabe erstellen",
"Create new ESXi credential": "Neue ESXi-Anmeldedaten erstellen",
"Create new Kerberos credential": "Neue Kerberos-Anmeldedaten erstellen",
"Create new SMB credential": "Neue SMB-Anmeldedaten erstellen",
"Create new SNMP credential": "Neue SNMP-Anmeldedaten erstellen",
"Create new SSH credential": "Neue SSH-Anmeldedaten erstellen",
Expand Down Expand Up @@ -953,6 +955,9 @@
"Issuer DN": "Aussteller DN",
"Items": "Objekte",
"Just wait for results to arrive.": "Bitte warten Sie auf Ergebnisse.",
"KDCs": "",
"Kerberos": "",
"Kerberos Credential": "Kerberos-Anmeldedaten",
"Known Hosts": "Bekannte Hosts",
"Last": "Letzte",
"Last Day": "Letzter Tag",
Expand Down Expand Up @@ -1289,7 +1294,6 @@
"Permissions Filter": "Berechtigungen-Filter",
"Permissions to create a ticket are insufficient. You need the create_permission and get_users permissions.": "Die Berechtigungen ein Ticket zu erstellen sind unzureichend. Sie benötigen die create_permission- und get_users-Berechtigungen.",
"PGP Encryption Key": "PGP-Verschlüsselungsschlüssel",
"PGP Public Key": "Öffentlicher PGP-Schlüssel",
"Physical": "Physisch",
"PKCS12 Credential": "PKCS12-Anmeldedaten",
"PKCS12 File": "PKCS12-Datei",
Expand Down Expand Up @@ -1337,6 +1341,7 @@
"Product": "Produkt",
"Product Detection Result": "Ergebnis zur Produkterkennung",
"Protocol": "Protokoll",
"Public Key": "Öffentlicher Schlüssel",
"Published": "Veröffentlicht",
"Published:": "Veröffentlicht:",
"QoD": "QdE",
Expand All @@ -1353,6 +1358,7 @@
"RADIUS Host": "RADIUS-Host",
"Random": "Zufällig",
"read": "Lese-",
"Realm": "",
"Recur on day(s)": "Wiederholen an Tag(en)",
"Recurrence": "Wiederholung",
"Reference Source": "Referenzquelle",
Expand Down
8 changes: 7 additions & 1 deletion public/locales/gsa-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"Close": "Close",
"Closed": "Closed",
"Closed CVEs": "Closed CVEs",
"Comma separated list of KDCs": "Comma separated list of KDCs",
"Comment": "Comment",
"Community": "Community",
"Complete": "Complete",
Expand Down Expand Up @@ -432,6 +433,7 @@
"Create new {{entity}}": "Create new {{entity}}",
"Create new Container Task": "Create new Container Task",
"Create new ESXi credential": "Create new ESXi credential",
"Create new Kerberos credential": "Create new Kerberos credential",
"Create new SMB credential": "Create new SMB credential",
"Create new SNMP credential": "Create new SNMP credential",
"Create new SSH credential": "Create new SSH credential",
Expand Down Expand Up @@ -953,6 +955,9 @@
"Issuer DN": "Issuer DN",
"Items": "Items",
"Just wait for results to arrive.": "Just wait for results to arrive.",
"KDCs": "KDCs",
"Kerberos": "Kerberos",
"Kerberos Credential": "Kerberos Credential",
"Known Hosts": "Known Hosts",
"Last": "Last",
"Last Day": "Last Day",
Expand Down Expand Up @@ -1289,7 +1294,6 @@
"Permissions Filter": "Permissions Filter",
"Permissions to create a ticket are insufficient. You need the create_permission and get_users permissions.": "Permissions to create a ticket are insufficient. You need the create_permission and get_users permissions.",
"PGP Encryption Key": "PGP Encryption Key",
"PGP Public Key": "PGP Public Key",
"Physical": "Physical",
"PKCS12 Credential": "PKCS12 Credential",
"PKCS12 File": "PKCS12 File",
Expand Down Expand Up @@ -1337,6 +1341,7 @@
"Product": "Product",
"Product Detection Result": "Product Detection Result",
"Protocol": "Protocol",
"Public Key": "Public Key",
"Published": "Published",
"Published:": "Published:",
"QoD": "QoD",
Expand All @@ -1353,6 +1358,7 @@
"RADIUS Host": "RADIUS Host",
"Random": "Random",
"read": "read",
"Realm": "Realm",
"Recur on day(s)": "Recur on day(s)",
"Recurrence": "Recurrence",
"Reference Source": "Reference Source",
Expand Down
8 changes: 7 additions & 1 deletion public/locales/gsa-zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"Close": "关闭",
"Closed": "关闭",
"Closed CVEs": "已关闭的CVEs",
"Comma separated list of KDCs": "",
"Comment": "描述",
"Community": "团体名",
"Complete": "完全",
Expand Down Expand Up @@ -432,6 +433,7 @@
"Create new {{entity}}": "创建新的{{entity}}",
"Create new Container Task": "创建新的任务容器",
"Create new ESXi credential": "",
"Create new Kerberos credential": "",
"Create new SMB credential": "",
"Create new SNMP credential": "",
"Create new SSH credential": "",
Expand Down Expand Up @@ -953,6 +955,9 @@
"Issuer DN": "颁发者DN",
"Items": "项目",
"Just wait for results to arrive.": "只需等待结果到来.",
"KDCs": "",
"Kerberos": "",
"Kerberos Credential": "",
"Known Hosts": "已知主机",
"Last": "尾页",
"Last Day": "最后一天",
Expand Down Expand Up @@ -1289,7 +1294,6 @@
"Permissions Filter": "权限筛选",
"Permissions to create a ticket are insufficient. You need the create_permission and get_users permissions.": "创建工单的权限不足.您需要create_permission和get_users权限.",
"PGP Encryption Key": "PGP加密密钥",
"PGP Public Key": "PGP公钥",
"Physical": "物理",
"PKCS12 Credential": "PKCS12 证书",
"PKCS12 File": "PKCS12 文件",
Expand Down Expand Up @@ -1337,6 +1341,7 @@
"Product": "产品",
"Product Detection Result": "产品检测结果",
"Protocol": "协议",
"Public Key": "",
"Published": "发布",
"Published:": "公布:",
"QoD": "QoD",
Expand All @@ -1353,6 +1358,7 @@
"RADIUS Host": "RADIUS 主机",
"Random": "随机",
"read": "读",
"Realm": "",
"Recur on day(s)": "在哪一天运行",
"Recurrence": "运行次数",
"Reference Source": "参考源",
Expand Down
8 changes: 7 additions & 1 deletion public/locales/gsa-zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"Close": "",
"Closed": "",
"Closed CVEs": "",
"Comma separated list of KDCs": "",
"Comment": "備註",
"Community": "",
"Complete": "完成",
Expand Down Expand Up @@ -432,6 +433,7 @@
"Create new {{entity}}": "",
"Create new Container Task": "",
"Create new ESXi credential": "",
"Create new Kerberos credential": "",
"Create new SMB credential": "",
"Create new SNMP credential": "",
"Create new SSH credential": "",
Expand Down Expand Up @@ -953,6 +955,9 @@
"Issuer DN": "簽發者",
"Items": "項目",
"Just wait for results to arrive.": "",
"KDCs": "",
"Kerberos": "",
"Kerberos Credential": "",
"Known Hosts": "已知主機",
"Last": "",
"Last Day": "最後一日",
Expand Down Expand Up @@ -1289,7 +1294,6 @@
"Permissions Filter": "",
"Permissions to create a ticket are insufficient. You need the create_permission and get_users permissions.": "",
"PGP Encryption Key": "",
"PGP Public Key": "PGP 公鑰",
"Physical": "",
"PKCS12 Credential": "PKCS12 憑證",
"PKCS12 File": "PKCS12 檔案",
Expand Down Expand Up @@ -1337,6 +1341,7 @@
"Product": "產品",
"Product Detection Result": "",
"Protocol": "通訊協定",
"Public Key": "",
"Published": "發佈日期",
"Published:": "發佈日期:",
"QoD": "",
Expand All @@ -1353,6 +1358,7 @@
"RADIUS Host": "",
"Random": "",
"read": "讀取",
"Realm": "",
"Recur on day(s)": "",
"Recurrence": "",
"Reference Source": "",
Expand Down
145 changes: 145 additions & 0 deletions src/gmp/commands/__tests__/credential.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/* SPDX-FileCopyrightText: 2025 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import {describe, test, expect} from '@gsa/testing';
import DefaultTransform from 'gmp/http/transform/default';

import {CredentialCommand} from '../credentials';
import {createHttp, createActionResultResponse} from '../testing';

describe('CredentialCommand tests', () => {
test('should create credential', async () => {
const response = createActionResultResponse();
const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new CredentialCommand(fakeHttp);
const resp = await cmd.create({name: 'test-credential'});

expect(fakeHttp.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'create_credential',
name: 'test-credential',
comment: '',
allow_insecure: 0,
autogenerate: 0,
community: '',
credential_login: '',
lsc_password: '',
passphrase: '',
privacy_password: '',
auth_algorithm: 'sha1',
privacy_algorithm: 'aes',
private_key: undefined,
public_key: undefined,
certificate: undefined,
realm: undefined,
kdc: undefined,
credential_type: undefined,
},
});

const {data} = resp;
expect(data.id).toEqual('foo');
});

test('should save credential', async () => {
const response = createActionResultResponse();
const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new CredentialCommand(fakeHttp);
const resp = await cmd.save({
id: '1',
name: 'updated-credential',
comment: 'updated comment',
allow_insecure: 1,
auth_algorithm: 'md5',
certificate: 'cert',
change_community: 1,
change_passphrase: 1,
change_password: 1,
change_privacy_password: 1,
community: 'community',
credential_login: 'login',
credential_type: 'type',
passphrase: 'passphrase',
password: 'password',
privacy_algorithm: 'des',
privacy_password: 'privacy_password',
private_key: 'private_key',
public_key: 'public_key',
});

expect(fakeHttp.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'save_credential',
credential_id: '1',
name: 'updated-credential',
comment: 'updated comment',
allow_insecure: 1,
auth_algorithm: 'md5',
certificate: 'cert',
change_community: 1,
change_passphrase: 1,
change_password: 1,
change_privacy_password: 1,
community: 'community',
credential_login: 'login',
credential_type: 'type',
passphrase: 'passphrase',
password: 'password',
privacy_algorithm: 'des',
privacy_password: 'privacy_password',
private_key: 'private_key',
public_key: 'public_key',
},
});

const {data} = resp;
expect(data.id).toEqual('foo');
});

test('should download credential', async () => {
const response = new ArrayBuffer(8);
const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new CredentialCommand(fakeHttp);
const resp = await cmd.download({id: '1'}, 'pem');

expect(fakeHttp.request).toHaveBeenCalledWith('get', {
args: {
cmd: 'download_credential',
package_format: 'pem',
credential_id: '1',
},
transform: DefaultTransform,
responseType: 'arraybuffer',
});

expect(resp).toEqual(response);
});

test('should get element from root', () => {
const root = {
// eslint-disable-next-line camelcase
get_credential: {
// eslint-disable-next-line camelcase
get_credentials_response: {
credential: {id: '1', name: 'test-credential'},
},
},
};

const cmd = new CredentialCommand();
const element = cmd.getElementFromRoot(root);

expect(element).toEqual({id: '1', name: 'test-credential'});
});
});
Loading