Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3261

S5122 should consider "HttpServletResponse.addHeader" in addition to "HttpServletResponse.setHeader"

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.1
    • Component/s: Rules
    • Labels:

      Description

      Today S5122 is going to report on such code:

      public void setCORS(HttpServletResponse resp) {
        resp.setHeader("Access-Control-Allow-Origin", "*");
      }
      

      It should also report on:

      public void addCORS(HttpServletResponse resp) {
        resp.addHeader("Access-Control-Allow-Origin", "*");
      }
      

      Also, an issue should be raised whatever the case of the header name because header names are not case sensitive: https://stackoverflow.com/a/5259004/4919399

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                alexandre.gigleux Alexandre Gigleux
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: