diff options
| author | Stefan Monnier | 2019-09-27 08:01:04 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-09-27 08:01:04 -0400 |
| commit | bda62c787f76f97ab8db913613223362656181fd (patch) | |
| tree | fea22d3e4694ae39213ee3a4c509892e0b1b156e | |
| parent | 5efd5515031ca65357732092f3f40e097ef52876 (diff) | |
| download | emacs-bda62c787f76f97ab8db913613223362656181fd.tar.gz emacs-bda62c787f76f97ab8db913613223362656181fd.zip | |
* lisp/net/nsm.el: Use lexical-binding
(nsm-check-tls-connection, nsm-query): Don't pass explicitly `obarray`
since it's the default anyway.
(nsm-query, nsm-query-user, nsm-save-host): Remove redundant
advertised-calling-convention.
| -rw-r--r-- | lisp/net/nsm.el | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el index b8c84d5fdea..4ca770fd7e1 100644 --- a/lisp/net/nsm.el +++ b/lisp/net/nsm.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; nsm.el --- Network Security Manager | 1 | ;;; nsm.el --- Network Security Manager -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2014-2019 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2014-2019 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -269,7 +269,7 @@ See also: `network-security-protocol-checks' and `nsm-noninteractive'" | |||
| 269 | (let* ((results | 269 | (let* ((results |
| 270 | (cl-loop | 270 | (cl-loop |
| 271 | for check in network-security-protocol-checks | 271 | for check in network-security-protocol-checks |
| 272 | for type = (intern (format ":%s" (car check)) obarray) | 272 | for type = (intern (format ":%s" (car check))) |
| 273 | ;; Skip the check if the user has already said that this | 273 | ;; Skip the check if the user has already said that this |
| 274 | ;; host is OK for this type of "error". | 274 | ;; host is OK for this type of "error". |
| 275 | for result = (and (not (memq type | 275 | for result = (and (not (memq type |
| @@ -278,8 +278,7 @@ See also: `network-security-protocol-checks' and `nsm-noninteractive'" | |||
| 278 | (nsm-level (cadr check))) | 278 | (nsm-level (cadr check))) |
| 279 | (funcall | 279 | (funcall |
| 280 | (intern (format "nsm-protocol-check--%s" | 280 | (intern (format "nsm-protocol-check--%s" |
| 281 | (car check)) | 281 | (car check))) |
| 282 | obarray) | ||
| 283 | host port status settings)) | 282 | host port status settings)) |
| 284 | when result | 283 | when result |
| 285 | collect (cons type result))) | 284 | collect (cons type result))) |
| @@ -321,7 +320,7 @@ See also: `network-security-protocol-checks' and `nsm-noninteractive'" | |||
| 321 | (declare-function gnutls-peer-status-warning-describe "gnutls.c" | 320 | (declare-function gnutls-peer-status-warning-describe "gnutls.c" |
| 322 | (status-symbol)) | 321 | (status-symbol)) |
| 323 | 322 | ||
| 324 | (defun nsm-protocol-check--verify-cert (host port status settings) | 323 | (defun nsm-protocol-check--verify-cert (_host _port status settings) |
| 325 | "Check for warnings from the certificate verification status. | 324 | "Check for warnings from the certificate verification status. |
| 326 | 325 | ||
| 327 | This is the most basic security check for a TLS connection. If | 326 | This is the most basic security check for a TLS connection. If |
| @@ -332,7 +331,7 @@ This is the most basic security check for a TLS connection. If | |||
| 332 | (not (nsm-warnings-ok-p status settings)) | 331 | (not (nsm-warnings-ok-p status settings)) |
| 333 | (mapconcat #'gnutls-peer-status-warning-describe warnings "\n")))) | 332 | (mapconcat #'gnutls-peer-status-warning-describe warnings "\n")))) |
| 334 | 333 | ||
| 335 | (defun nsm-protocol-check--same-cert (host port status settings) | 334 | (defun nsm-protocol-check--same-cert (_host _port status settings) |
| 336 | "Check for certificate fingerprint mismatch. | 335 | "Check for certificate fingerprint mismatch. |
| 337 | 336 | ||
| 338 | If the fingerprints saved do not match the fingerprint of the | 337 | If the fingerprints saved do not match the fingerprint of the |
| @@ -344,7 +343,7 @@ man-in-the-middle attack." | |||
| 344 | 343 | ||
| 345 | ;; Key exchange checks | 344 | ;; Key exchange checks |
| 346 | 345 | ||
| 347 | (defun nsm-protocol-check--rsa-kx (host port status &optional settings) | 346 | (defun nsm-protocol-check--rsa-kx (_host _port status &optional _settings) |
| 348 | "Check for static RSA key exchange. | 347 | "Check for static RSA key exchange. |
| 349 | 348 | ||
| 350 | Static RSA key exchange methods do not offer perfect forward | 349 | Static RSA key exchange methods do not offer perfect forward |
| @@ -374,7 +373,7 @@ Security (DTLS)\", \"(4.1. General Guidelines)\" | |||
| 374 | "RSA key exchange method (%s) does not offer perfect forward secrecy" | 373 | "RSA key exchange method (%s) does not offer perfect forward secrecy" |
| 375 | kx)))) | 374 | kx)))) |
| 376 | 375 | ||
| 377 | (defun nsm-protocol-check--dhe-prime-kx (host port status &optional settings) | 376 | (defun nsm-protocol-check--dhe-prime-kx (_host _port status &optional _settings) |
| 378 | "Check for the key strength of DH key exchange based on integer factorization. | 377 | "Check for the key strength of DH key exchange based on integer factorization. |
| 379 | 378 | ||
| 380 | This check is a response to Logjam[1]. Logjam is an attack that | 379 | This check is a response to Logjam[1]. Logjam is an attack that |
| @@ -405,7 +404,7 @@ Diffie-Hellman Fails in Practice\", `https://weakdh.org/' | |||
| 405 | "Diffie-Hellman key strength (%s bits) too weak (%s bits)" | 404 | "Diffie-Hellman key strength (%s bits) too weak (%s bits)" |
| 406 | prime-bits 1024)))) | 405 | prime-bits 1024)))) |
| 407 | 406 | ||
| 408 | (defun nsm-protocol-check--dhe-kx (host port status &optional settings) | 407 | (defun nsm-protocol-check--dhe-kx (_host _port status &optional _settings) |
| 409 | "Check for existence of DH key exchange based on integer factorization. | 408 | "Check for existence of DH key exchange based on integer factorization. |
| 410 | 409 | ||
| 411 | In the years since the discovery of Logjam, it was discovered | 410 | In the years since the discovery of Logjam, it was discovered |
| @@ -429,7 +428,7 @@ Diffie-Hellman Backdoors in TLS.\", | |||
| 429 | "unable to verify Diffie-Hellman key exchange method (%s) parameters" | 428 | "unable to verify Diffie-Hellman key exchange method (%s) parameters" |
| 430 | kx)))) | 429 | kx)))) |
| 431 | 430 | ||
| 432 | (defun nsm-protocol-check--export-kx (host port status &optional settings) | 431 | (defun nsm-protocol-check--export-kx (_host _port status &optional _settings) |
| 433 | "Check for RSA-EXPORT key exchange. | 432 | "Check for RSA-EXPORT key exchange. |
| 434 | 433 | ||
| 435 | EXPORT cipher suites are a family of 40-bit and 56-bit effective | 434 | EXPORT cipher suites are a family of 40-bit and 56-bit effective |
| @@ -454,7 +453,7 @@ of user-visible changes.\" Version 3.4.0, | |||
| 454 | "EXPORT level key exchange (%s) is insecure" | 453 | "EXPORT level key exchange (%s) is insecure" |
| 455 | kx))))) | 454 | kx))))) |
| 456 | 455 | ||
| 457 | (defun nsm-protocol-check--anon-kx (host port status &optional settings) | 456 | (defun nsm-protocol-check--anon-kx (_host _port status &optional _settings) |
| 458 | "Check for anonymous key exchange. | 457 | "Check for anonymous key exchange. |
| 459 | 458 | ||
| 460 | Anonymous key exchange exposes the connection to | 459 | Anonymous key exchange exposes the connection to |
| @@ -473,7 +472,7 @@ authentication\", | |||
| 473 | 472 | ||
| 474 | ;; Cipher checks | 473 | ;; Cipher checks |
| 475 | 474 | ||
| 476 | (defun nsm-protocol-check--cbc-cipher (host port status &optional settings) | 475 | (defun nsm-protocol-check--cbc-cipher (_host _port status &optional _settings) |
| 477 | "Check for CBC mode ciphers. | 476 | "Check for CBC mode ciphers. |
| 478 | 477 | ||
| 479 | CBC mode cipher in TLS versions earlier than 1.3 are problematic | 478 | CBC mode cipher in TLS versions earlier than 1.3 are problematic |
| @@ -502,7 +501,7 @@ Security (TLS) and Datagram Transport Layer Security (DTLS)\", | |||
| 502 | "CBC mode cipher (%s) can be insecure" | 501 | "CBC mode cipher (%s) can be insecure" |
| 503 | cipher))))) | 502 | cipher))))) |
| 504 | 503 | ||
| 505 | (defun nsm-protocol-check--ecdsa-cbc-cipher (host port status &optional settings) | 504 | (defun nsm-protocol-check--ecdsa-cbc-cipher (_host _port status &optional _settings) |
| 506 | "Check for CBC mode cipher usage under ECDSA key exchange. | 505 | "Check for CBC mode cipher usage under ECDSA key exchange. |
| 507 | 506 | ||
| 508 | CBC mode cipher in TLS versions earlier than 1.3 are problematic | 507 | CBC mode cipher in TLS versions earlier than 1.3 are problematic |
| @@ -540,7 +539,7 @@ Security (TLS) and Datagram Transport Layer Security (DTLS)\", | |||
| 540 | "CBC mode cipher (%s) can be insecure" | 539 | "CBC mode cipher (%s) can be insecure" |
| 541 | cipher))))) | 540 | cipher))))) |
| 542 | 541 | ||
| 543 | (defun nsm-protocol-check--3des-cipher (host port status &optional settings) | 542 | (defun nsm-protocol-check--3des-cipher (_host _port status &optional _settings) |
| 544 | "Check for 3DES ciphers. | 543 | "Check for 3DES ciphers. |
| 545 | 544 | ||
| 546 | Due to its use of 64-bit block size, it is known that a | 545 | Due to its use of 64-bit block size, it is known that a |
| @@ -561,7 +560,7 @@ Current Use and Deprecation of TDEA\", | |||
| 561 | "3DES cipher (%s) is weak" | 560 | "3DES cipher (%s) is weak" |
| 562 | cipher)))) | 561 | cipher)))) |
| 563 | 562 | ||
| 564 | (defun nsm-protocol-check--rc4-cipher (host port status &optional settings) | 563 | (defun nsm-protocol-check--rc4-cipher (_host _port status &optional _settings) |
| 565 | "Check for RC4 ciphers. | 564 | "Check for RC4 ciphers. |
| 566 | 565 | ||
| 567 | RC4 cipher has been prohibited by RFC 7465[1]. | 566 | RC4 cipher has been prohibited by RFC 7465[1]. |
| @@ -585,7 +584,7 @@ Reference: | |||
| 585 | 584 | ||
| 586 | ;; Signature checks | 585 | ;; Signature checks |
| 587 | 586 | ||
| 588 | (defun nsm-protocol-check--sha1-sig (host port status &optional settings) | 587 | (defun nsm-protocol-check--sha1-sig (_host _port status &optional _settings) |
| 589 | "Check for SHA1 signatures on certificates. | 588 | "Check for SHA1 signatures on certificates. |
| 590 | 589 | ||
| 591 | The first SHA1 collision was found in 2017[1], as a precaution | 590 | The first SHA1 collision was found in 2017[1], as a precaution |
| @@ -620,7 +619,7 @@ SHA-1 for SSL/TLS Certificates in Microsoft Edge and Internet Explorer | |||
| 620 | algo) | 619 | algo) |
| 621 | end)) | 620 | end)) |
| 622 | 621 | ||
| 623 | (defun nsm-protocol-check--md5-sig (host port status &optional settings) | 622 | (defun nsm-protocol-check--md5-sig (_host _port status &optional _settings) |
| 624 | "Check for MD5 signatures on certificates. | 623 | "Check for MD5 signatures on certificates. |
| 625 | 624 | ||
| 626 | In 2008, a group of researchers were able to forge an | 625 | In 2008, a group of researchers were able to forge an |
| @@ -653,8 +652,8 @@ the MD5 Message-Digest and the HMAC-MD5 Algorithms\", | |||
| 653 | 652 | ||
| 654 | ;; Extension checks | 653 | ;; Extension checks |
| 655 | 654 | ||
| 656 | (defun nsm-protocol-check--renegotiation-info-ext (host port status | 655 | (defun nsm-protocol-check--renegotiation-info-ext (_host _port status |
| 657 | &optional settings) | 656 | &optional _settings) |
| 658 | "Check for renegotiation_info TLS extension status. | 657 | "Check for renegotiation_info TLS extension status. |
| 659 | 658 | ||
| 660 | If this TLS extension is not used, the connection established is | 659 | If this TLS extension is not used, the connection established is |
| @@ -676,7 +675,7 @@ Layer Security (TLS) Renegotiation Indication Extension\", | |||
| 676 | 675 | ||
| 677 | ;; Compression checks | 676 | ;; Compression checks |
| 678 | 677 | ||
| 679 | (defun nsm-protocol-check--compression (host port status &optional settings) | 678 | (defun nsm-protocol-check--compression (_host _port status &optional _settings) |
| 680 | "Check for TLS compression. | 679 | "Check for TLS compression. |
| 681 | 680 | ||
| 682 | TLS compression attacks such as CRIME would allow an attacker to | 681 | TLS compression attacks such as CRIME would allow an attacker to |
| @@ -697,7 +696,7 @@ Security (DTLS)\", `https://tools.ietf.org/html/rfc7525'" | |||
| 697 | 696 | ||
| 698 | ;; Protocol version checks | 697 | ;; Protocol version checks |
| 699 | 698 | ||
| 700 | (defun nsm-protocol-check--version (host port status &optional settings) | 699 | (defun nsm-protocol-check--version (_host _port status &optional _settings) |
| 701 | "Check for SSL/TLS protocol version. | 700 | "Check for SSL/TLS protocol version. |
| 702 | 701 | ||
| 703 | This function guards against the usage of SSL3.0, which has been | 702 | This function guards against the usage of SSL3.0, which has been |
| @@ -722,7 +721,7 @@ Early TLS\" | |||
| 722 | 721 | ||
| 723 | ;; Full suite checks | 722 | ;; Full suite checks |
| 724 | 723 | ||
| 725 | (defun nsm-protocol-check--null-suite (host port status &optional settings) | 724 | (defun nsm-protocol-check--null-suite (_host _port status &optional _settings) |
| 726 | "Check for NULL cipher suites. | 725 | "Check for NULL cipher suites. |
| 727 | 726 | ||
| 728 | This function checks for NULL key exchange, cipher and message | 727 | This function checks for NULL key exchange, cipher and message |
| @@ -790,8 +789,7 @@ protocol." | |||
| 790 | (let ((response | 789 | (let ((response |
| 791 | (condition-case nil | 790 | (condition-case nil |
| 792 | (intern | 791 | (intern |
| 793 | (car (split-string (nsm-query-user message status))) | 792 | (car (split-string (nsm-query-user message status)))) |
| 794 | obarray) | ||
| 795 | ;; Make sure we manage to close the process if the user hits | 793 | ;; Make sure we manage to close the process if the user hits |
| 796 | ;; `C-g'. | 794 | ;; `C-g'. |
| 797 | (quit 'no) | 795 | (quit 'no) |
| @@ -807,9 +805,6 @@ protocol." | |||
| 807 | (nsm-save-host host port status what problems response) | 805 | (nsm-save-host host port status what problems response) |
| 808 | t)))) | 806 | t)))) |
| 809 | 807 | ||
| 810 | (set-advertised-calling-convention | ||
| 811 | 'nsm-query '(host port status what problems message) "27.1") | ||
| 812 | |||
| 813 | (declare-function gnutls-format-certificate "gnutls.c" (cert)) | 808 | (declare-function gnutls-format-certificate "gnutls.c" (cert)) |
| 814 | 809 | ||
| 815 | (defun nsm-query-user (message status) | 810 | (defun nsm-query-user (message status) |
| @@ -923,8 +918,6 @@ protocol." | |||
| 923 | (kill-buffer cert-buffer) | 918 | (kill-buffer cert-buffer) |
| 924 | (kill-buffer buffer))))) | 919 | (kill-buffer buffer))))) |
| 925 | 920 | ||
| 926 | (set-advertised-calling-convention 'nsm-query-user '(message status) "27.1") | ||
| 927 | |||
| 928 | (defun nsm-save-host (host port status what problems permanency) | 921 | (defun nsm-save-host (host port status what problems permanency) |
| 929 | (let* ((id (nsm-id host port)) | 922 | (let* ((id (nsm-id host port)) |
| 930 | (saved-fingerprints (plist-get (nsm-host-settings id) :fingerprints)) | 923 | (saved-fingerprints (plist-get (nsm-host-settings id) :fingerprints)) |
| @@ -964,11 +957,6 @@ protocol." | |||
| 964 | (nsm-remove-temporary-setting id) | 957 | (nsm-remove-temporary-setting id) |
| 965 | (push saved nsm-temporary-host-settings)))) | 958 | (push saved nsm-temporary-host-settings)))) |
| 966 | 959 | ||
| 967 | (set-advertised-calling-convention | ||
| 968 | 'nsm-save-host | ||
| 969 | '(host port status what problems permanency) | ||
| 970 | "27.1") | ||
| 971 | |||
| 972 | (defun nsm-write-settings () | 960 | (defun nsm-write-settings () |
| 973 | (with-temp-file nsm-settings-file | 961 | (with-temp-file nsm-settings-file |
| 974 | (insert "(\n") | 962 | (insert "(\n") |