Skip to content

Commit 124f057

Browse files
authored
Merge pull request #1767 from jrha/cleanup-ssh
ncm-ssh: Cleanup pan templates
2 parents 934cfac + 4001143 commit 124f057

File tree

3 files changed

+49
-25
lines changed

3 files changed

+49
-25
lines changed

ncm-ssh/src/main/pan/components/ssh/schema-5.3.pan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
declaration template components/ssh/schema-5.3;
88

99
type ssh_authkeyscommand_options_type = {
10-
"AuthorizedKeysCommand" ? string
11-
"AuthorizedKeysCommandRunAs" ? string
10+
"AuthorizedKeysCommand" ? string
11+
"AuthorizedKeysCommandRunAs" ? string
1212
};

ncm-ssh/src/main/pan/components/ssh/schema.pan

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@ variable SSH_SCHEMA_VERSION ?= '5.3';
1212

1313
include 'components/ssh/schema-' + SSH_SCHEMA_VERSION;
1414

15-
type ssh_preferred_authentication = string with match(SELF, '^(gssapi-with-mic|hostbased|publickey' +
16-
'|keyboard-interactive|password)$');
17-
15+
type ssh_preferred_authentication = choice(
16+
'gssapi-with-mic',
17+
'hostbased',
18+
'keyboard-interactive',
19+
'password',
20+
'publickey'
21+
);
1822

1923
type ssh_ciphers = string with is_valid_ssh_cipher(SELF);
20-
type ssh_hostkeyalgorithms = string with match(SELF, "^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp(256|384|521)" +
21-
"(ssh-rsa-cert-v01|ssh-dss-cert-v01|ecdsa-sha2-nistp256-cert-v01|ecdsa-sha2-nistp384-cert-v01|" +
22-
"|ecdsa-sha2-nistp521-cert-v01|ssh-rsa-cert-v00|ssh-dss-cert-v00|ssh-ed25519-cert-v01)@openssh.com)$");
23-
type ssh_kbdinteractivedevices = string with match (SELF, "^(bsdauth|pam|skey)$");
24-
type ssh_kexalgorithms = string with match (SELF, "^(diffie-hellman-group-exchange-sha256|" +
25-
"ecdh-sha2-nistp(256|384|521)|[email protected])$");
24+
25+
type ssh_kexalgorithms = choice(
26+
'diffie-hellman-group-exchange-sha256',
27+
'ecdh-sha2-nistp256',
28+
'ecdh-sha2-nistp384',
29+
'ecdh-sha2-nistp521',
30+
31+
);
32+
2633
type ssh_MACs = string with is_valid_ssh_MAC(SELF);
34+
2735
type ssh_gssapikexalgorithms = choice(
2836
'gss-gex-sha1-',
2937
'gss-group1-sha1-',
@@ -35,17 +43,32 @@ type ssh_gssapikexalgorithms = choice(
3543
);
3644

3745
function is_valid_ssh_MAC = {
38-
match(ARGV[0], "^(hmac-(sha2-256|sha2-512|ripemd160)|(hmac-ripemd160|umac-64|umac-128|hmac-sha2-256-etm" +
39-
"|hmac-sha2-512-etm|hmac-ripemd160-etm|umac-64-etm|umac-128-etm)@openssh.com)$");
46+
valid_options = list(
47+
'hmac-ripemd160',
48+
49+
50+
'hmac-sha2-256',
51+
52+
'hmac-sha2-512',
53+
54+
55+
56+
57+
58+
);
59+
index(ARGV[0], valid_options) >= 0;
4060
};
4161

4262
function is_valid_ssh_cipher = {
43-
match (ARGV[0], "^((aes128|aes192|aes256)-ctr|(aes128-gcm|aes256-gcm|chacha20-poly1305)@openssh.com)$");
44-
};
45-
46-
function is_valid_ssh_kexalgorithm = {
47-
match (ARGV[0], "^(diffie-hellman-group-exchange-sha256|ecdh-sha2-nistp(256|384|521)|" +
48-
63+
valid_options = list(
64+
'aes128-ctr',
65+
'aes192-ctr',
66+
'aes256-ctr',
67+
68+
69+
70+
);
71+
index(ARGV[0], valid_options) >= 0;
4972
};
5073

5174
type legacy_ssh_MACs = string with {
@@ -76,17 +99,17 @@ type legacy_ssh_kexalgorithm = string with {
7699
};
77100

78101
type ssh_core_options_type = {
79-
"AddressFamily" ? string with match (SELF, '^(any|inet6?)$')
102+
"AddressFamily" ? choice('any', 'inet', 'inet6')
80103
"ChallengeResponseAuthentication" ? legacy_binary_affirmation_string
81104
"Ciphers" ? legacy_ssh_ciphers
82-
"Compression" ? string with match (SELF, '^(yes|delayed|no)$')
105+
"Compression" ? choice('yes', 'delayed', 'no')
83106
"GSSAPIAuthentication" ? legacy_binary_affirmation_string
84107
"GSSAPICleanupCredentials" ? legacy_binary_affirmation_string
85108
"GSSAPIKexAlgorithms" ? ssh_gssapikexalgorithms[1..]
86109
"GSSAPIKeyExchange" ? legacy_binary_affirmation_string
87110
"GatewayPorts" ? legacy_binary_affirmation_string
88111
"HostbasedAuthentication" ? legacy_binary_affirmation_string
89-
"LogLevel" ? string with match (SELF, '^(QUIET|FATAL|ERROR|INFO|VERBOSE|DEBUG[123]?)$')
112+
"LogLevel" ? choice('QUIET', 'FATAL', 'ERROR', 'INFO', 'VERBOSE', 'DEBUG1', 'DEBUG2', 'DEBUG3')
90113
"MACs" ? legacy_ssh_MACs
91114
"PasswordAuthentication" ? legacy_binary_affirmation_string
92115
"Protocol" ? string
@@ -150,7 +173,7 @@ type ssh_daemon_options_type = {
150173
};
151174
true;
152175
}
153-
"PermitTunnel" ? string with match (SELF, '^(yes|point-to-point|ethernet|no)$')
176+
"PermitTunnel" ? choice('yes', 'point-to-point', 'ethernet', 'no')
154177
"PermitUserEnvironment" ? legacy_binary_affirmation_string
155178
"PidFile" ? string
156179
"Port" ? long
@@ -168,7 +191,8 @@ type ssh_daemon_options_type = {
168191
"StrictModes" ? legacy_binary_affirmation_string
169192
"Subsystem" ? string
170193
"SyslogFacility" ? string with match (SELF,
171-
'^(AUTH(PRIV)?|DAEMON|USER|KERN|UUCP|NEWS|MAIL|SYSLOG|LPR|FTP|CRON|LOCAL[0-7])$')
194+
'^(AUTH(PRIV)?|DAEMON|USER|KERN|UUCP|NEWS|MAIL|SYSLOG|LPR|FTP|CRON|LOCAL[0-7])$'
195+
)
172196
"TcpRcvBuf" ? long
173197
"TcpRcvBufPoll" ? legacy_binary_affirmation_string
174198
"UseDNS" ? legacy_binary_affirmation_string

ncm-ssh/src/test/resources/ssh_simple.pan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ prefix "/software/components/ssh/daemon/comment_options";
1616
"Banner" = "Foobar";
1717

1818
prefix "/software/components/ssh/client/options";
19-
"PreferredAuthentications" = list('gssapi-with-mic','hostbased','publickey');
19+
"PreferredAuthentications" = list('gssapi-with-mic', 'hostbased', 'publickey');
2020
"Port" = 22222;

0 commit comments

Comments
 (0)