Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to exclude some operations from security-defined rule #1569

Closed
RomanHotsiy opened this issue May 27, 2024 · 4 comments · Fixed by #1570
Closed

Ability to exclude some operations from security-defined rule #1569

RomanHotsiy opened this issue May 27, 2024 · 4 comments · Fixed by #1570

Comments

@RomanHotsiy
Copy link
Member

Is your feature request related to a problem? Please describe.

Very often API define a health endpoint which is not protected by any kind of auth.

Our security-defined rule always reports this as a problem.

Surely, it can be ignored with ignore file but this is a problem for users who constantly onboard new APIs.
Configurable rule can't be used here as it doesn't cover security defined on different levels (operation vs root).

Describe the solution you'd like

Add support for exceptions config option to the rule:

rules:
  security-defined:
    severity: error
    exceptions:
      - path: '/health'
        method: GET

Describe alternatives you've considered

I used exceptions as we use this term in path-segment-plural rule. Let me know if you have better suggestions.

Another alternative is to have a simpler list of exceptions (only path)

rules:
  security-defined:
    severity: error
    exceptions:
      - '/health'

What do you think?

@tatomyr
Copy link
Contributor

tatomyr commented May 27, 2024

I like the first approach better as it allows fine-grained exceptions. However, I'd make the method property plural to be able to specify several methods. Also, we can make it optional and ignore an entire path if there are no methods specified.

@adamaltman
Copy link
Member

FYI:

If you define security on the operation or path item as security: [] it means security is explicitly defined as no security, it won't trigger the rule.

I mention it in the docs here: https://redocly.com/docs/cli/rules/security-defined/#api-design-principles

@tatomyr
Copy link
Contributor

tatomyr commented May 28, 2024

@RomanHotsiy do you think we still need this adjustment? Is there a case that couldn't be easily covered by the empty security as @adamaltman suggests?

@RomanHotsiy
Copy link
Member Author

Yes. Still makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants