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

feat: add ability to exclude some operations from security-defined rule #1570

Merged
merged 4 commits into from
May 29, 2024

Conversation

tatomyr
Copy link
Contributor

@tatomyr tatomyr commented May 27, 2024

What/Why/How?

Adds the ability to exclude some paths or particular operations from the security-defined rule.

Here's an example:

redocly.yaml

rules:  
  security-defined: 
    exceptions:
      - path: /partially-skipped
        methods:
          - get
      - path: /fully-skipped

openapi.yaml

openapi: 3.1.0
paths:
  /partially-skipped:
    get:
      description: Skipped.
    post: 
      description: Has security.
      security: []
    delete: 
      description: Should have security defined!
  /fully-skipped:
    get:
      description: Skipped.
    post: 
      description: Skipped.
  /required:
    get: 
      summary: Should have security defined!

The ouput:

image

Reference

Resolves: #1569

Testing

Screenshots (optional)

Check yourself

  • Code changed? - Tested with redoc/reference-docs/workflows (internal)
  • All new/updated code is covered with tests
  • New package installed? - Tested in different environments (browser/node)

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

@tatomyr tatomyr requested review from a team as code owners May 27, 2024 15:08
@tatomyr tatomyr self-assigned this May 27, 2024
Copy link

changeset-bot bot commented May 27, 2024

🦋 Changeset detected

Latest commit: 3aa0951

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@redocly/openapi-core Minor
@redocly/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented May 27, 2024

Command Mean [ms] Min [ms] Max [ms] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 988.5 ± 72.7 930.2 1178.6 1.01 ± 0.08
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 979.2 ± 20.3 959.3 1028.8 1.00

Copy link
Contributor

github-actions bot commented May 27, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 77.26% 4485/5805
🟡 Branches 67.57% 2479/3669
🟡 Functions 70.94% 747/1053
🟡 Lines 77.45% 4218/5446

Test suite run success

738 tests passing in 102 suites.

Report generated by 🧪jest coverage report action from 3aa0951

Copy link
Member

@RomanHotsiy RomanHotsiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@lornajane
Copy link
Collaborator

Looking at #1569 , it would be better to have the users declare the security as open than to omit it - the benefit to the user is that the good practice is part of their OpenAPI description so will apply throughout the lifecycle and all tools.

@RomanHotsiy
Copy link
Member

Looking at #1569 , it would be better to have the users declare the security as open than to omit it - the benefit to the user is that the good practice is part of their OpenAPI description so will apply throughout the lifecycle and all tools.

Yes! Definitely it's better and that's why we have this rule. Unfortunately there are cases when it can't be done due to various reasons (like not controlling the openapi description directly multiplied by 100s of APIs). So it's good to have some way for exceptions.

@tatomyr tatomyr force-pushed the feat/exclude-operations-in-security-defined branch from 8a59a0d to 3aa0951 Compare May 28, 2024 15:33
@tatomyr tatomyr merged commit f6cce63 into main May 29, 2024
32 checks passed
@tatomyr tatomyr deleted the feat/exclude-operations-in-security-defined branch May 29, 2024 06:13
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.

Ability to exclude some operations from security-defined rule
4 participants