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

Reduce false positives in unquoted-attribute-var rule #3214

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion generic/html-templates/security/unquoted-attribute-var.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="600" />
<!-- ok -->
<!-- ok: unquoted-attribute-var -->
<meta property="not-real-only-for-testing" content="{{ safe }}" />

<!-- Google OAuth sign-in -->
Expand Down Expand Up @@ -83,3 +83,68 @@ <h3> rule: <a href="https://semgrep.dev/r?q={{check_id}}"> {{check_id}} </a> </h
</ul>
<hr/>
{% endfor %}

<!-- Octane engine used in newer versions of ember.js -->

<TodoList as |item|>
<!-- ok: unquoted-attribute-var -->
<Todo @item={{item}} />
</TodoList>

<!-- ok: unquoted-attribute-var -->
<MyGreeting @params={{array "Hello" "World"}}>

<!-- ok: unquoted-attribute-var -->
<h1>{{@title}}</h1>

<!-- ok: unquoted-attribute-var -->
<h1>{{this.title}}</h1>

<!-- ok: unquoted-attribute-var -->
<h1>{{or @title "Untitled"}}</h1>

<Message::Avatar
// ok: unquoted-attribute-var
@title="{{@username}}'s avatar"
// ok: unquoted-attribute-var
@initial={{@avatarInitial}}
// ok: unquoted-attribute-var
@initial={{substring @username 0 1}}
// ok: unquoted-attribute-var
@isActive={{@userIsActive}}
// ok: unquoted-attribute-var
class={{if @isCurrentUser "current-user"}}
/>
<section>
<Message::Username
// ok: unquoted-attribute-var
@name={{@username}}
// ok: unquoted-attribute-var
@localTime={{@userLocalTime}}
/>

{{yield}}
</section>

<button
type="button"
// todook: unquoted-attribute-var
{{on "click" this.onClickShowDropdown}}
>
More Actions
</button>
<div id="dropdown-destination" />

<MyDropdownComponent
// ok: unquoted-attribute-var
@show={{this.showDropdown}}
/>

<MyComponent
// ok: unquoted-attribute-var
@people={{array
'Tom Dale'
'Yehuda Katz'
this.myOtherPerson
}}
/>
2 changes: 2 additions & 0 deletions generic/html-templates/security/unquoted-attribute-var.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ rules:
- pattern-inside: <$TAG ...>
- pattern-not-inside: ="..."
- pattern-not-inside: ='...'
- pattern-not-inside: |
@$ATTRIBUTE={{ ... }}
- pattern: '{{ ... }}'
fix-regex:
regex: '{{(.*?)}}'
Expand Down
Loading