Skip to content

Add support for my use cases#170

Open
kBite wants to merge 11 commits intovoxpupuli:masterfrom
kBite:add-support-for-my-use-cases
Open

Add support for my use cases#170
kBite wants to merge 11 commits intovoxpupuli:masterfrom
kBite:add-support-for-my-use-cases

Conversation

@kBite
Copy link
Copy Markdown
Contributor

@kBite kBite commented Jan 29, 2024

  1. some "idempotent" (non user-visible) changes

    • make parameters and headers more readable
      • it's opinionated, but pretty much inline with what other modules do
    • refactor defined type rule moving boilerplate to new function
    • simplify rule with some new data types
  2. add support for my use cases

    • add parameters outerface, daddr_type, saddr_type, and ctstate

Of course, everything comes with tests and documentation. I didn't add tests for the function though, because I'd consider it tested indirectly as part of tests done on rule.

EDIT: Tests are failing due to outdated REFERENCE.md. Can't find redcarpet right now. Tried ...

$ bundle exec gem install redcarpet
Fetching redcarpet-3.6.0.gem
Building native extensions. This could take a while...
Successfully installed redcarpet-3.6.0
1 gem installed

$ gem install --user redcarpet
Building native extensions. This could take a while...
Successfully installed redcarpet-3.6.0
Parsing documentation for redcarpet-3.6.0
Done installing documentation for redcarpet after 0 seconds
1 gem installed

$ gem install redcarpet
Building native extensions. This could take a while...
Successfully installed redcarpet-3.6.0
Parsing documentation for redcarpet-3.6.0
Done installing documentation for redcarpet after 0 seconds
1 gem installed

... but still:

$ bundle exec rake strings:generate
[error]: Missing 'redcarpet' gem for Markdown formatting. Install it with `gem install redcarpet`

Will dig deeper tomorrow.

@kBite kBite requested review from bastelfreak and foxxx0 January 29, 2024 19:25
@kBite kBite force-pushed the add-support-for-my-use-cases branch 2 times, most recently from 0c9b852 to c1a8056 Compare January 29, 2024 19:36
@smortex
Copy link
Copy Markdown
Member

smortex commented Jan 30, 2024

REFERENCE.md is outdated

Please update REFERENCE.md with

$ bundle exec rake strings:generate:reference

Add it to the PR and CI should continue.

@kBite kBite force-pushed the add-support-for-my-use-cases branch 2 times, most recently from fe778fb to 8acfc06 Compare January 30, 2024 13:59
@kBite kBite force-pushed the add-support-for-my-use-cases branch from 8acfc06 to 9e167eb Compare February 17, 2025 11:55
@kengelhardt-godaddy kengelhardt-godaddy mentioned this pull request Feb 17, 2025
@kBite kBite force-pushed the add-support-for-my-use-cases branch from 9e167eb to e3b4f8c Compare February 17, 2025 12:32
@kBite
Copy link
Copy Markdown
Contributor Author

kBite commented Feb 17, 2025

@bastelfreak rebased against master

Regenerating README.md doesn't work for me:

(add-support-for-my-use-cases=) $ bundle exec rake strings:generate:reference
Could not find gem 'voxpupuli-test (~> 9.0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

bundle fails to find ruby

(add-support-for-my-use-cases=) $ bundle install --path .vendor/ --without system_tests --without development --without release
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "ruby":
  In Gemfile:
    ruby

    puppet (>= 7.24, < 9) was resolved to 7.34.0, which depends on
      facter (> 2.0.1, < 5) was resolved to 4.10.0, which depends on
        ruby (>= 2.5, < 4.0)

    overcommit (>= 0.39.1) was resolved to 0.67.0, which depends on
      ruby (>= 2.6)

    puppet (>= 7.24, < 9) was resolved to 7.34.0, which depends on
      ruby (>= 2.5.0)

    voxpupuli-test (~> 9.0) was resolved to 9.2.0, which depends on
      ruby (>= 2.7.0)

Seems like the common demoninator is Ruby 2.6.0

(add-support-for-my-use-cases=) $ tree .vendor/
.vendor/
└── ruby
    └── 2.6.0

3 directories, 0 files

@kBite kBite self-assigned this Feb 17, 2025
If 'Ferm::Actions' is equal to some defined strings or any non-empty
string it's almost useless. For this reason the defined type 'rule' has
to reiterate testing against the same Enum to get useful information
from it.

'Ferm::Actions' is used in 'rule' and 'ipset'. The later does not seem
to require jumping.

update spec/type_aliases/actions_spec.rb
- Originally 'daddr' and 'saddr' were of data type 'Variant[Array, String[1]]'
- In case of Array code matched against 'Array[Stdlib::IP::Address]'

Keeping 'String[1]' for compatibility

add test for new data type 'Ferm::Address'
replace single long line with heredoc

add test for 'outerface'
add test for data type 'addr_type'
add test for new addr_type parameters
iptables syntax:
  ```
  -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  ```

ferm syntax:
  ```
  table filter FORWARD outerface docker0 mod conntrack ctstate (ESTABLISHED RELATED) ACCEPT;
  ```

add test for new 'ctstate' parameter
@kBite kBite force-pushed the add-support-for-my-use-cases branch from e3b4f8c to a66b48f Compare April 7, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants