go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/sshd/params.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package sshd
     5  
     6  import (
     7  	"strings"
     8  )
     9  
    10  func Params(content string) (map[string]string, error) {
    11  	lines := strings.Split(content, "\n")
    12  
    13  	res := make(map[string]string)
    14  	for _, textLine := range lines {
    15  		l, err := ParseLine([]rune(textLine))
    16  		if err != nil {
    17  			return nil, err
    18  		}
    19  
    20  		k := l.key
    21  		if k == "" {
    22  			continue
    23  		}
    24  
    25  		// handle lower case entries and use proper ssh camel case
    26  		if sshKey, ok := SSH_Keywords[strings.ToLower(k)]; ok {
    27  			k = sshKey
    28  		}
    29  
    30  		// check if we have an entry already
    31  		if val, ok := res[k]; ok {
    32  			res[k] = val + "," + l.args
    33  		} else {
    34  			res[k] = l.args
    35  		}
    36  	}
    37  
    38  	return res, nil
    39  }
    40  
    41  var SSH_Keywords = map[string]string{
    42  	"acceptenv":                       "AcceptEnv",
    43  	"addressfamily":                   "AddressFamily",
    44  	"allowagentforwarding":            "AllowAgentForwarding",
    45  	"allowgroups":                     "AllowGroups",
    46  	"allowstreamlocalforwarding":      "AllowStreamLocalForwarding",
    47  	"allowtcpforwarding":              "AllowTcpForwarding",
    48  	"allowusers":                      "AllowUsers",
    49  	"authenticationmethods":           "AuthenticationMethods",
    50  	"authorizedkeyscommand":           "AuthorizedKeysCommand",
    51  	"authorizedkeyscommanduser":       "AuthorizedKeysCommandUser",
    52  	"authorizedkeysfile":              "AuthorizedKeysFile",
    53  	"authorizedprincipalscommand":     "AuthorizedPrincipalsCommand",
    54  	"authorizedprincipalscommanduser": "AuthorizedPrincipalsCommandUser",
    55  	"authorizedprincipalsfile":        "AuthorizedPrincipalsFile",
    56  	"banner":                          "Banner",
    57  	"casignaturealgorithms":           "CASignatureAlgorithms",
    58  	"challengeresponseauthentication": "ChallengeResponseAuthentication",
    59  	"chrootdirectory":                 "ChrootDirectory",
    60  	"ciphers":                         "Ciphers",
    61  	"clientalivecountmax":             "ClientAliveCountMax",
    62  	"clientaliveinterval":             "ClientAliveInterval",
    63  	"compression":                     "Compression",
    64  	"denygroups":                      "DenyGroups",
    65  	"denyusers":                       "DenyUsers",
    66  	"disableforwarding":               "DisableForwarding",
    67  	"exposeauthinfo":                  "ExposeAuthInfo",
    68  	"fingerprinthash":                 "FingerprintHash",
    69  	"forcecommand":                    "ForceCommand",
    70  	"gssapiauthentication":            "GSSAPIAuthentication",
    71  	"gssapicleanupcredentials":        "GSSAPICleanupCredentials",
    72  	"gssapistrictacceptorcheck":       "GSSAPIStrictAcceptorCheck",
    73  	"gatewayports":                    "GatewayPorts",
    74  	"hostcertificate":                 "HostCertificate",
    75  	"hostkey":                         "HostKey",
    76  	"hostkeyagent":                    "HostKeyAgent",
    77  	"hostkeyalgorithms":               "HostKeyAlgorithms",
    78  	"hostbasedacceptedkeytypes":       "HostbasedAcceptedKeyTypes",
    79  	"hostbasedauthentication":         "HostbasedAuthentication",
    80  	"hostbasedusesnamefrompacketonly": "HostbasedUsesNameFromPacketOnly",
    81  	"ipqos":                           "IPQoS",
    82  	"ignorerhosts":                    "IgnoreRhosts",
    83  	"ignoreuserknownhosts":            "IgnoreUserKnownHosts",
    84  	"include":                         "Include",
    85  	"kbdinteractiveauthentication":    "KbdInteractiveAuthentication",
    86  	"kerberosauthentication":          "KerberosAuthentication",
    87  	"kerberosgetafstoken":             "KerberosGetAFSToken",
    88  	"kerberosorlocalpasswd":           "KerberosOrLocalPasswd",
    89  	"kerberosticketcleanup":           "KerberosTicketCleanup",
    90  	"kexalgorithms":                   "KexAlgorithms",
    91  	"listenaddress":                   "ListenAddress",
    92  	"loglevel":                        "LogLevel",
    93  	"logingracetime":                  "LoginGraceTime",
    94  	"macs":                            "MACs",
    95  	"match":                           "Match",
    96  	"maxauthtries":                    "MaxAuthTries",
    97  	"maxsessions":                     "MaxSessions",
    98  	"maxstartups":                     "MaxStartups",
    99  	"passwordauthentication":          "PasswordAuthentication",
   100  	"permitemptypasswords":            "PermitEmptyPasswords",
   101  	"permitlisten":                    "PermitListen",
   102  	"permitopen":                      "PermitOpen",
   103  	"permitrootlogin":                 "PermitRootLogin",
   104  	"permittty":                       "PermitTTY",
   105  	"permittunnel":                    "PermitTunnel",
   106  	"permituserenvironment":           "PermitUserEnvironment",
   107  	"permituserrc":                    "PermitUserRC",
   108  	"pidfile":                         "PidFile",
   109  	"port":                            "Port",
   110  	"printlastlog":                    "PrintLastLog",
   111  	"printmotd":                       "PrintMotd",
   112  	"pubkeyacceptedkeytypes":          "PubkeyAcceptedKeyTypes",
   113  	"pubkeyauthoptions":               "PubkeyAuthOptions",
   114  	"pubkeyauthentication":            "PubkeyAuthentication",
   115  	"rdomain":                         "RDomain",
   116  	"rekeylimit":                      "RekeyLimit",
   117  	"revokedkeys":                     "RevokedKeys",
   118  	"securitykeyprovider":             "SecurityKeyProvider",
   119  	"setenv":                          "SetEnv",
   120  	"streamlocalbindmask":             "StreamLocalBindMask",
   121  	"streamlocalbindunlink":           "StreamLocalBindUnlink",
   122  	"strictmodes":                     "StrictModes",
   123  	"subsystem":                       "Subsystem",
   124  	"syslogfacility":                  "SyslogFacility",
   125  	"tcpkeepalive":                    "TCPKeepAlive",
   126  	"trustedusercakeys":               "TrustedUserCAKeys",
   127  	"usedns":                          "UseDNS",
   128  	"usepam":                          "UsePAM",
   129  	"versionaddendum":                 "VersionAddendum",
   130  	"x11displayoffset":                "X11DisplayOffset",
   131  	"x11forwarding":                   "X11Forwarding",
   132  	"x11uselocalhost":                 "X11UseLocalhost",
   133  	"xauthlocation":                   "XAuthLocation",
   134  }