Browse Source

deny modified to `insert 1`

This change puts deny rules at the top of the rule table to guarnatee
they execute first and deny before other rules might allow.
develop
Rob Colbert 2 years ago
parent
commit
c4fee21a4f
  1. 4
      src/methods/Deny.ts

4
src/methods/Deny.ts

@ -10,7 +10,7 @@ async function port(port: number, protocol?: PortProtocol) {
let checkPort = checkAppropriatePort(port);
if (!checkPort) return false;
let command = await runCommand(`echo "y" | sudo ufw ${shouldDryRunDuringTesting} deny ${port}${protocol ? `/${protocol}` : ""}`);
let command = await runCommand(`echo "y" | sudo ufw ${shouldDryRunDuringTesting} insert 1 deny ${port}${protocol ? `/${protocol}` : ""}`);
return command ? isAddedOrUpdated(command) : false;
} catch (err) {
throw err;
@ -32,7 +32,7 @@ async function address(address: string, port?: number, protocol?: PortProtocol)
if (!checkPort) return false;
};
let command = await runCommand(`echo "y" | sudo ufw ${shouldDryRunDuringTesting} deny from ${address} ${port ? `to any port ${port}` : ""} ${protocol ? `proto ${protocol}` : ""}`);
let command = await runCommand(`echo "y" | sudo ufw ${shouldDryRunDuringTesting} ufw insert 1 deny from ${address} ${port ? `to any port ${port}` : ""} ${protocol ? `proto ${protocol}` : ""}`);
return command ? isAddedOrUpdated(command) : false;
} catch (err) {
throw err;

Loading…
Cancel
Save