<commit_before>local _M = {}

local shell_execute = require "resty.auto-ssl.utils.shell_execute"

function _M.issue_cert(auto_ssl_instance, domain)
  local package_root = auto_ssl_instance.package_root
  local base_dir = auto_ssl_instance:get("dir")

  local env_vars =
    "env HOOK_SECRET=" .. ngx.shared.auto_ssl:get("hook_server:secret") .. " " ..
    "HOOK_SERVER_PORT=" .. auto_ssl_instance:get("hook_server_port")

  -- Run dehydrated for this domain, using our custom hooks to handle the
  -- domain validation and the issued certificates.
  --
  -- Disable dehydrated's locking, since we perform our own domain-specific
  -- locking using the storage adapter.
  local command = env_vars .. " " ..
    package_root .. "/auto-ssl/vendor/dehydrated " ..
    "--cron " ..
    "--no-lock " ..
    "--domain " .. domain .. " " ..
    "--challenge http-01 " ..
    "--config " .. base_dir .. "/letsencrypt/config " ..
    "--hook " .. package_root .. "/auto-ssl/shell/letsencrypt_hooks"
  local status, out, err = shell_execute(command)
  if status ~= 0 then
    ngx.log(ngx.ERR, "auto-ssl: dehydrated failed: ", command, " status: ", status, " out: ", out, " err: ", err)<commit_msg>add sanity-checks for hook_server_port<commit_after>local _M = {}

local shell_execute = require "resty.auto-ssl.utils.shell_execute"

function _M.issue_cert(auto_ssl_instance, domain)
  local package_root = auto_ssl_instance.package_root
  local base_dir = auto_ssl_instance:get("dir")
  local hook_port = auto_ssl_instance:get("hook_server_port")

  assert(type(hook_port) == "number", "hook_port must be a number")
  assert(hook_port <= 65535, "hook_port must be below 65536")

  local env_vars =
    "env HOOK_SECRET=" .. ngx.shared.auto_ssl:get("hook_server:secret") .. " " ..
    "HOOK_SERVER_PORT=" .. hook_port

  -- Run dehydrated for this domain, using our custom hooks to handle the
  -- domain validation and the issued certificates.
  --
  -- Disable dehydrated's locking, since we perform our own domain-specific
  -- locking using the storage adapter.
  local command = env_vars .. " " ..
    package_root .. "/auto-ssl/vendor/dehydrated " ..
    "--cron " ..
    "--no-lock " ..
    "--domain " .. domain .. " " ..
    "--challenge http-01 " ..
    "--config " .. base_dir .. "/letsencrypt/config " ..
    "--hook " .. package_root .. "/auto-ssl/shell/letsencrypt_hooks"
  local status, out, err = shell_execute(command)
  if status ~= 0 then
    ngx.log(ngx.ERR, "auto-ssl: dehydrated failed: ", command, " status: ", status, " out: ", out, " err: ", err)
{'fraction_non_alphanumeric': 0.1493354182955434, 'fraction_numerical': 0.006254886630179828, 'mean_word_length': 3.1009615384615383, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2395936', 'n_tokens_mistral': 865, 'n_tokens_neox': 822, 'n_words': 201}