SCW Icons
hero bg no divider
Blog

Java の落とし穴-ビット演算子とブール演算子

アラン・リチャードソン
Published Feb 07, 2021
Last updated on Mar 10, 2026

Java Gotchas - Bitwise vs Boolean Operators

> "Java Gotcha" - a common mistake pattern that is easy to accidentally implement.

A fairly simple Java Gotcha to accidentally fall into is: using a Bitwise operator instead of a Boolean Comparison operator.

e.g. a simple mistype can result in writing "&" when you really meant to write "&&".

A common heuristic we learn when reviewing code is:

> "&" or "|" when used in a conditional statement is probably not intended.

In this blog post, we will explore the heuristic and identify ways we can identify and fix this coding issue.


What's the Problem? Bitwise operations work fine with Booleans


Using Bitwise operators with Booleans is perfectly valid, so Java will not report a syntax error.

If I construct a JUnit Test to explore a truth table for both Bitwise OR (|) and Bitwise AND (&) then we will see that the outputs from the Bitwise operator match the truth table. Given this, we might think that the use of Bitwise operators is not an issue.

AND Truth Table

Three columns on with a, one with b, and the last with (a^b)


@Test
    void bitwiseOperatorsAndTruthTable(){
          Assertions.assertEquals(true, true & true);
          Assertions.assertEquals(false, true & false);
          Assertions.assertEquals(false, false & true);
          Assertions.assertEquals(false, false & false);
    }


The test passes, this is perfectly valid Java.


OR Truth Table


Three columns on with a, one with b, and the last with (a v b)


   @Test
    void bitwiseOperatorsOrTruthTable(){
        Assertions.assertEquals(true, true | true);
        Assertions.assertEquals(true, true | false);
        Assertions.assertEquals(true, false | true);
        Assertions.assertEquals(false, false | false);
    }


This test also passes, why do we prefer "&&'and "||'?


Truth table images were created using the truth table tool from web.standfor.edu.


Issue: Short Circuit Operation


The real issue is the difference in behaviour between Bitwise (&, |) and Boolean (&&, ||) operators.

A Boolean operator is a short circuit operator and only evaluates as much as it needs to.

e.g.

if (args != null & args.length() > 23) {
    System.out.println(args);
}


In the above code, both boolean conditions will evaluate, because the Bitwise operator has been used:

  • args != null
  • args.length() > 23

This leaves my code open to a NullPointerException if args is null because we will always perform the check for args.length, even when args is null because both boolean conditions have to be evaluated.


Boolean Operators Short Circuit Evaluation


When an && is used e.g.

if (args != null && args.length() > 23) {
    System.out.println(args);
}


As soon as we know that args != null evaluates to false the condition expression evaluation stops.

We don't need to evaluate the right-hand side.

Whatever the outcome of the right-hand side condition, the final value of the Boolean expression will be false.


But this would never happen in production code


This is a pretty easy mistake to make and is not always picked up by Static Analysis tools.

I used the following Google Dork to see if I could find any public examples of this pattern:

filetype:java if "!=null & "
This search brought back some code from Android in the RootWindowContainer
isDocument = intent != null & intent.isDocument()


This is the type of code that might pass a code review because we often do use Bitwise operators in assignment statements to mask values. But in this instance, the outcome is the same as the if statement example above. If intent is ever null, then a NullPointerException will be thrown.

Very often we get away with this construct because we often code defensively and write redundant code. The check for != null may well be redundant in most use cases.

This is an error made by programmers in production code.

I don't know how current the results for the search are, but when I ran the search there were results back with code from: Google, Amazon, Apache... and me.

A recent pull request on one of my open source projects was to address exactly this error.

if(type!=null & type.trim().length()>0){
    acceptMediaTypeDefinitionsList.add(type.trim());
}


How to Find This


When I checked my sample code in a few static analysers, none of them picked up this hidden self-destruct code.

As a team at Secure Code Warrior, we created and reviewed a fairly simple Sensei recipe that could pick this up.

Because Bitwise operators are perfectly valid, and often used in assignments we focussed on the use-case of if statements, and the use of Bitwise &, to find the problematic code.

search:
  expression:
    anyOf:
    - in:
        condition: {}
    value:
      caseSensitive: false
      matches: ".* & .*"


This uses a regular expression to match " & " when it is used as a condition expression. e.g. in an if statement.

To fix it, we again relied on regular expressions. This time using the sed function in the QuickFix to globally replace the & in the expression with &&.

availableFixes:
  - name: "Replace bitwise AND operator to logical AND operator"
    actions:
      - rewrite:
          to: "{{#sed}}s/&/&&/g,{{{ . }}}{{/sed}}"


End Notes

This covers the most common misuse of a Bitwise operator, i.e. when a Boolean operator was actually intended.

There are other situations where this could crop up e.g. the assignment example, but when writing recipes we have to attempt to avoid false-positive identification, otherwise recipes will be ignored or turned off. We build recipes to match the most common occurrences. As Sensei evolves, we may well add additional specificity into the search functionality to cover more matching conditions.

In its current form, this recipe would identify many of the live use-cases, and most importantly, the one that was reported in my project.

NOTE: A fair few code warriors contributed to this example and recipe review - Charlie Eriksen, Matthieu Calie, Robin Claerhaut, Brysen Ackx, Nathan Desmet, Downey Robersscheuten. Thanks for your help.


---


You can install Sensei from within IntelliJ using "Preferences \ Plugins" (Mac) or "Settings \ Plugins" (Windows) then just search for "sensei secure code"

We have a lot of source code and recipes for these blog posts (including this one) in the `sensei-blog-examples` repository in the Secure Code Warrior GitHub account.

https://github.com/securecodewarrior/sensei-blog-examples

Learn more about Sensei


リソースを表示
リソースを表示

このブログ記事では、よくあるJavaコーディングの間違い (条件演算子の代わりにビット演算子の使用)、それによってコードが脆弱になるエラー、およびSenseiを使用して問題を修正および検出する方法について見ていきます。

もっと興味がありますか?

Alan Richardson は 20 年以上にわたり、開発者として、テスターからテスト責任者まで、テスト階層のあらゆるレベルで経験を積んできました。Secure Code Warrior の開発者リレーションズの責任者であり、チームと直接連携して、高品質で安全なコードの開発を改善しています。アランは、「ディア・イーブル・テスター」と「Java フォー・テスター」を含む4冊の本の著者です。また、アランはテクニカル・ウェブ・テストと Java を使った Selenium WebDriver を学ぶのに役立つオンライン・トレーニング・コースも作成しています。アランは SeleniumSimplified.com、EvilTester.com、JavaForTesters.com、CompendiumDev.co.uk にライティングとトレーニングのビデオを投稿しています。

learn more

Secure Code Warriorは、ソフトウェア開発ライフサイクル全体にわたってコードを保護し、サイバーセキュリティを最優先とする文化を築くお手伝いをします。アプリケーションセキュリティマネージャ、開発者、CISO、またはセキュリティ関係者のいずれであっても、安全でないコードに関連するリスクを軽減するお手伝いをします。

デモを予約
シェア:
linkedin brandsSocialx logo
著者
アラン・リチャードソン
Published Feb 07, 2021

Alan Richardson は 20 年以上にわたり、開発者として、テスターからテスト責任者まで、テスト階層のあらゆるレベルで経験を積んできました。Secure Code Warrior の開発者リレーションズの責任者であり、チームと直接連携して、高品質で安全なコードの開発を改善しています。アランは、「ディア・イーブル・テスター」と「Java フォー・テスター」を含む4冊の本の著者です。また、アランはテクニカル・ウェブ・テストと Java を使った Selenium WebDriver を学ぶのに役立つオンライン・トレーニング・コースも作成しています。アランは SeleniumSimplified.com、EvilTester.com、JavaForTesters.com、CompendiumDev.co.uk にライティングとトレーニングのビデオを投稿しています。

シェア:
linkedin brandsSocialx logo

Java Gotchas - Bitwise vs Boolean Operators

> "Java Gotcha" - a common mistake pattern that is easy to accidentally implement.

A fairly simple Java Gotcha to accidentally fall into is: using a Bitwise operator instead of a Boolean Comparison operator.

e.g. a simple mistype can result in writing "&" when you really meant to write "&&".

A common heuristic we learn when reviewing code is:

> "&" or "|" when used in a conditional statement is probably not intended.

In this blog post, we will explore the heuristic and identify ways we can identify and fix this coding issue.


What's the Problem? Bitwise operations work fine with Booleans


Using Bitwise operators with Booleans is perfectly valid, so Java will not report a syntax error.

If I construct a JUnit Test to explore a truth table for both Bitwise OR (|) and Bitwise AND (&) then we will see that the outputs from the Bitwise operator match the truth table. Given this, we might think that the use of Bitwise operators is not an issue.

AND Truth Table

Three columns on with a, one with b, and the last with (a^b)


@Test
    void bitwiseOperatorsAndTruthTable(){
          Assertions.assertEquals(true, true & true);
          Assertions.assertEquals(false, true & false);
          Assertions.assertEquals(false, false & true);
          Assertions.assertEquals(false, false & false);
    }


The test passes, this is perfectly valid Java.


OR Truth Table


Three columns on with a, one with b, and the last with (a v b)


   @Test
    void bitwiseOperatorsOrTruthTable(){
        Assertions.assertEquals(true, true | true);
        Assertions.assertEquals(true, true | false);
        Assertions.assertEquals(true, false | true);
        Assertions.assertEquals(false, false | false);
    }


This test also passes, why do we prefer "&&'and "||'?


Truth table images were created using the truth table tool from web.standfor.edu.


Issue: Short Circuit Operation


The real issue is the difference in behaviour between Bitwise (&, |) and Boolean (&&, ||) operators.

A Boolean operator is a short circuit operator and only evaluates as much as it needs to.

e.g.

if (args != null & args.length() > 23) {
    System.out.println(args);
}


In the above code, both boolean conditions will evaluate, because the Bitwise operator has been used:

  • args != null
  • args.length() > 23

This leaves my code open to a NullPointerException if args is null because we will always perform the check for args.length, even when args is null because both boolean conditions have to be evaluated.


Boolean Operators Short Circuit Evaluation


When an && is used e.g.

if (args != null && args.length() > 23) {
    System.out.println(args);
}


As soon as we know that args != null evaluates to false the condition expression evaluation stops.

We don't need to evaluate the right-hand side.

Whatever the outcome of the right-hand side condition, the final value of the Boolean expression will be false.


But this would never happen in production code


This is a pretty easy mistake to make and is not always picked up by Static Analysis tools.

I used the following Google Dork to see if I could find any public examples of this pattern:

filetype:java if "!=null & "
This search brought back some code from Android in the RootWindowContainer
isDocument = intent != null & intent.isDocument()


This is the type of code that might pass a code review because we often do use Bitwise operators in assignment statements to mask values. But in this instance, the outcome is the same as the if statement example above. If intent is ever null, then a NullPointerException will be thrown.

Very often we get away with this construct because we often code defensively and write redundant code. The check for != null may well be redundant in most use cases.

This is an error made by programmers in production code.

I don't know how current the results for the search are, but when I ran the search there were results back with code from: Google, Amazon, Apache... and me.

A recent pull request on one of my open source projects was to address exactly this error.

if(type!=null & type.trim().length()>0){
    acceptMediaTypeDefinitionsList.add(type.trim());
}


How to Find This


When I checked my sample code in a few static analysers, none of them picked up this hidden self-destruct code.

As a team at Secure Code Warrior, we created and reviewed a fairly simple Sensei recipe that could pick this up.

Because Bitwise operators are perfectly valid, and often used in assignments we focussed on the use-case of if statements, and the use of Bitwise &, to find the problematic code.

search:
  expression:
    anyOf:
    - in:
        condition: {}
    value:
      caseSensitive: false
      matches: ".* & .*"


This uses a regular expression to match " & " when it is used as a condition expression. e.g. in an if statement.

To fix it, we again relied on regular expressions. This time using the sed function in the QuickFix to globally replace the & in the expression with &&.

availableFixes:
  - name: "Replace bitwise AND operator to logical AND operator"
    actions:
      - rewrite:
          to: "{{#sed}}s/&/&&/g,{{{ . }}}{{/sed}}"


End Notes

This covers the most common misuse of a Bitwise operator, i.e. when a Boolean operator was actually intended.

There are other situations where this could crop up e.g. the assignment example, but when writing recipes we have to attempt to avoid false-positive identification, otherwise recipes will be ignored or turned off. We build recipes to match the most common occurrences. As Sensei evolves, we may well add additional specificity into the search functionality to cover more matching conditions.

In its current form, this recipe would identify many of the live use-cases, and most importantly, the one that was reported in my project.

NOTE: A fair few code warriors contributed to this example and recipe review - Charlie Eriksen, Matthieu Calie, Robin Claerhaut, Brysen Ackx, Nathan Desmet, Downey Robersscheuten. Thanks for your help.


---


You can install Sensei from within IntelliJ using "Preferences \ Plugins" (Mac) or "Settings \ Plugins" (Windows) then just search for "sensei secure code"

We have a lot of source code and recipes for these blog posts (including this one) in the `sensei-blog-examples` repository in the Secure Code Warrior GitHub account.

https://github.com/securecodewarrior/sensei-blog-examples

Learn more about Sensei


リソースを表示
リソースを表示

レポートをダウンロードするには、以下のフォームに記入してください

当社の製品および/または関連するセキュアコーディングのトピックに関する情報を送信する許可をお願いします。当社は、お客様の個人情報を常に細心の注意を払って取り扱い、マーケティング目的で他社に販売することは決してありません。

送信
scw success icon
scw error icon
フォームを送信するには、「アナリティクス」クッキーを有効にしてください。設定が完了したら、再度無効にしても構いません。

Java Gotchas - Bitwise vs Boolean Operators

> "Java Gotcha" - a common mistake pattern that is easy to accidentally implement.

A fairly simple Java Gotcha to accidentally fall into is: using a Bitwise operator instead of a Boolean Comparison operator.

e.g. a simple mistype can result in writing "&" when you really meant to write "&&".

A common heuristic we learn when reviewing code is:

> "&" or "|" when used in a conditional statement is probably not intended.

In this blog post, we will explore the heuristic and identify ways we can identify and fix this coding issue.


What's the Problem? Bitwise operations work fine with Booleans


Using Bitwise operators with Booleans is perfectly valid, so Java will not report a syntax error.

If I construct a JUnit Test to explore a truth table for both Bitwise OR (|) and Bitwise AND (&) then we will see that the outputs from the Bitwise operator match the truth table. Given this, we might think that the use of Bitwise operators is not an issue.

AND Truth Table

Three columns on with a, one with b, and the last with (a^b)


@Test
    void bitwiseOperatorsAndTruthTable(){
          Assertions.assertEquals(true, true & true);
          Assertions.assertEquals(false, true & false);
          Assertions.assertEquals(false, false & true);
          Assertions.assertEquals(false, false & false);
    }


The test passes, this is perfectly valid Java.


OR Truth Table


Three columns on with a, one with b, and the last with (a v b)


   @Test
    void bitwiseOperatorsOrTruthTable(){
        Assertions.assertEquals(true, true | true);
        Assertions.assertEquals(true, true | false);
        Assertions.assertEquals(true, false | true);
        Assertions.assertEquals(false, false | false);
    }


This test also passes, why do we prefer "&&'and "||'?


Truth table images were created using the truth table tool from web.standfor.edu.


Issue: Short Circuit Operation


The real issue is the difference in behaviour between Bitwise (&, |) and Boolean (&&, ||) operators.

A Boolean operator is a short circuit operator and only evaluates as much as it needs to.

e.g.

if (args != null & args.length() > 23) {
    System.out.println(args);
}


In the above code, both boolean conditions will evaluate, because the Bitwise operator has been used:

  • args != null
  • args.length() > 23

This leaves my code open to a NullPointerException if args is null because we will always perform the check for args.length, even when args is null because both boolean conditions have to be evaluated.


Boolean Operators Short Circuit Evaluation


When an && is used e.g.

if (args != null && args.length() > 23) {
    System.out.println(args);
}


As soon as we know that args != null evaluates to false the condition expression evaluation stops.

We don't need to evaluate the right-hand side.

Whatever the outcome of the right-hand side condition, the final value of the Boolean expression will be false.


But this would never happen in production code


This is a pretty easy mistake to make and is not always picked up by Static Analysis tools.

I used the following Google Dork to see if I could find any public examples of this pattern:

filetype:java if "!=null & "
This search brought back some code from Android in the RootWindowContainer
isDocument = intent != null & intent.isDocument()


This is the type of code that might pass a code review because we often do use Bitwise operators in assignment statements to mask values. But in this instance, the outcome is the same as the if statement example above. If intent is ever null, then a NullPointerException will be thrown.

Very often we get away with this construct because we often code defensively and write redundant code. The check for != null may well be redundant in most use cases.

This is an error made by programmers in production code.

I don't know how current the results for the search are, but when I ran the search there were results back with code from: Google, Amazon, Apache... and me.

A recent pull request on one of my open source projects was to address exactly this error.

if(type!=null & type.trim().length()>0){
    acceptMediaTypeDefinitionsList.add(type.trim());
}


How to Find This


When I checked my sample code in a few static analysers, none of them picked up this hidden self-destruct code.

As a team at Secure Code Warrior, we created and reviewed a fairly simple Sensei recipe that could pick this up.

Because Bitwise operators are perfectly valid, and often used in assignments we focussed on the use-case of if statements, and the use of Bitwise &, to find the problematic code.

search:
  expression:
    anyOf:
    - in:
        condition: {}
    value:
      caseSensitive: false
      matches: ".* & .*"


This uses a regular expression to match " & " when it is used as a condition expression. e.g. in an if statement.

To fix it, we again relied on regular expressions. This time using the sed function in the QuickFix to globally replace the & in the expression with &&.

availableFixes:
  - name: "Replace bitwise AND operator to logical AND operator"
    actions:
      - rewrite:
          to: "{{#sed}}s/&/&&/g,{{{ . }}}{{/sed}}"


End Notes

This covers the most common misuse of a Bitwise operator, i.e. when a Boolean operator was actually intended.

There are other situations where this could crop up e.g. the assignment example, but when writing recipes we have to attempt to avoid false-positive identification, otherwise recipes will be ignored or turned off. We build recipes to match the most common occurrences. As Sensei evolves, we may well add additional specificity into the search functionality to cover more matching conditions.

In its current form, this recipe would identify many of the live use-cases, and most importantly, the one that was reported in my project.

NOTE: A fair few code warriors contributed to this example and recipe review - Charlie Eriksen, Matthieu Calie, Robin Claerhaut, Brysen Ackx, Nathan Desmet, Downey Robersscheuten. Thanks for your help.


---


You can install Sensei from within IntelliJ using "Preferences \ Plugins" (Mac) or "Settings \ Plugins" (Windows) then just search for "sensei secure code"

We have a lot of source code and recipes for these blog posts (including this one) in the `sensei-blog-examples` repository in the Secure Code Warrior GitHub account.

https://github.com/securecodewarrior/sensei-blog-examples

Learn more about Sensei


オンラインセミナーを見る
始めよう
learn more

以下のリンクをクリックして、このリソースのPDFをダウンロードしてください。

Secure Code Warriorは、ソフトウェア開発ライフサイクル全体にわたってコードを保護し、サイバーセキュリティを最優先とする文化を築くお手伝いをします。アプリケーションセキュリティマネージャ、開発者、CISO、またはセキュリティ関係者のいずれであっても、安全でないコードに関連するリスクを軽減するお手伝いをします。

レポートを表示デモを予約
PDF をダウンロード
リソースを表示
シェア:
linkedin brandsSocialx logo
もっと興味がありますか?

シェア:
linkedin brandsSocialx logo
著者
アラン・リチャードソン
Published Feb 07, 2021

Alan Richardson は 20 年以上にわたり、開発者として、テスターからテスト責任者まで、テスト階層のあらゆるレベルで経験を積んできました。Secure Code Warrior の開発者リレーションズの責任者であり、チームと直接連携して、高品質で安全なコードの開発を改善しています。アランは、「ディア・イーブル・テスター」と「Java フォー・テスター」を含む4冊の本の著者です。また、アランはテクニカル・ウェブ・テストと Java を使った Selenium WebDriver を学ぶのに役立つオンライン・トレーニング・コースも作成しています。アランは SeleniumSimplified.com、EvilTester.com、JavaForTesters.com、CompendiumDev.co.uk にライティングとトレーニングのビデオを投稿しています。

シェア:
linkedin brandsSocialx logo

Java Gotchas - Bitwise vs Boolean Operators

> "Java Gotcha" - a common mistake pattern that is easy to accidentally implement.

A fairly simple Java Gotcha to accidentally fall into is: using a Bitwise operator instead of a Boolean Comparison operator.

e.g. a simple mistype can result in writing "&" when you really meant to write "&&".

A common heuristic we learn when reviewing code is:

> "&" or "|" when used in a conditional statement is probably not intended.

In this blog post, we will explore the heuristic and identify ways we can identify and fix this coding issue.


What's the Problem? Bitwise operations work fine with Booleans


Using Bitwise operators with Booleans is perfectly valid, so Java will not report a syntax error.

If I construct a JUnit Test to explore a truth table for both Bitwise OR (|) and Bitwise AND (&) then we will see that the outputs from the Bitwise operator match the truth table. Given this, we might think that the use of Bitwise operators is not an issue.

AND Truth Table

Three columns on with a, one with b, and the last with (a^b)


@Test
    void bitwiseOperatorsAndTruthTable(){
          Assertions.assertEquals(true, true & true);
          Assertions.assertEquals(false, true & false);
          Assertions.assertEquals(false, false & true);
          Assertions.assertEquals(false, false & false);
    }


The test passes, this is perfectly valid Java.


OR Truth Table


Three columns on with a, one with b, and the last with (a v b)


   @Test
    void bitwiseOperatorsOrTruthTable(){
        Assertions.assertEquals(true, true | true);
        Assertions.assertEquals(true, true | false);
        Assertions.assertEquals(true, false | true);
        Assertions.assertEquals(false, false | false);
    }


This test also passes, why do we prefer "&&'and "||'?


Truth table images were created using the truth table tool from web.standfor.edu.


Issue: Short Circuit Operation


The real issue is the difference in behaviour between Bitwise (&, |) and Boolean (&&, ||) operators.

A Boolean operator is a short circuit operator and only evaluates as much as it needs to.

e.g.

if (args != null & args.length() > 23) {
    System.out.println(args);
}


In the above code, both boolean conditions will evaluate, because the Bitwise operator has been used:

  • args != null
  • args.length() > 23

This leaves my code open to a NullPointerException if args is null because we will always perform the check for args.length, even when args is null because both boolean conditions have to be evaluated.


Boolean Operators Short Circuit Evaluation


When an && is used e.g.

if (args != null && args.length() > 23) {
    System.out.println(args);
}


As soon as we know that args != null evaluates to false the condition expression evaluation stops.

We don't need to evaluate the right-hand side.

Whatever the outcome of the right-hand side condition, the final value of the Boolean expression will be false.


But this would never happen in production code


This is a pretty easy mistake to make and is not always picked up by Static Analysis tools.

I used the following Google Dork to see if I could find any public examples of this pattern:

filetype:java if "!=null & "
This search brought back some code from Android in the RootWindowContainer
isDocument = intent != null & intent.isDocument()


This is the type of code that might pass a code review because we often do use Bitwise operators in assignment statements to mask values. But in this instance, the outcome is the same as the if statement example above. If intent is ever null, then a NullPointerException will be thrown.

Very often we get away with this construct because we often code defensively and write redundant code. The check for != null may well be redundant in most use cases.

This is an error made by programmers in production code.

I don't know how current the results for the search are, but when I ran the search there were results back with code from: Google, Amazon, Apache... and me.

A recent pull request on one of my open source projects was to address exactly this error.

if(type!=null & type.trim().length()>0){
    acceptMediaTypeDefinitionsList.add(type.trim());
}


How to Find This


When I checked my sample code in a few static analysers, none of them picked up this hidden self-destruct code.

As a team at Secure Code Warrior, we created and reviewed a fairly simple Sensei recipe that could pick this up.

Because Bitwise operators are perfectly valid, and often used in assignments we focussed on the use-case of if statements, and the use of Bitwise &, to find the problematic code.

search:
  expression:
    anyOf:
    - in:
        condition: {}
    value:
      caseSensitive: false
      matches: ".* & .*"


This uses a regular expression to match " & " when it is used as a condition expression. e.g. in an if statement.

To fix it, we again relied on regular expressions. This time using the sed function in the QuickFix to globally replace the & in the expression with &&.

availableFixes:
  - name: "Replace bitwise AND operator to logical AND operator"
    actions:
      - rewrite:
          to: "{{#sed}}s/&/&&/g,{{{ . }}}{{/sed}}"


End Notes

This covers the most common misuse of a Bitwise operator, i.e. when a Boolean operator was actually intended.

There are other situations where this could crop up e.g. the assignment example, but when writing recipes we have to attempt to avoid false-positive identification, otherwise recipes will be ignored or turned off. We build recipes to match the most common occurrences. As Sensei evolves, we may well add additional specificity into the search functionality to cover more matching conditions.

In its current form, this recipe would identify many of the live use-cases, and most importantly, the one that was reported in my project.

NOTE: A fair few code warriors contributed to this example and recipe review - Charlie Eriksen, Matthieu Calie, Robin Claerhaut, Brysen Ackx, Nathan Desmet, Downey Robersscheuten. Thanks for your help.


---


You can install Sensei from within IntelliJ using "Preferences \ Plugins" (Mac) or "Settings \ Plugins" (Windows) then just search for "sensei secure code"

We have a lot of source code and recipes for these blog posts (including this one) in the `sensei-blog-examples` repository in the Secure Code Warrior GitHub account.

https://github.com/securecodewarrior/sensei-blog-examples

Learn more about Sensei


目次

PDF をダウンロード
リソースを表示
もっと興味がありますか?

Alan Richardson は 20 年以上にわたり、開発者として、テスターからテスト責任者まで、テスト階層のあらゆるレベルで経験を積んできました。Secure Code Warrior の開発者リレーションズの責任者であり、チームと直接連携して、高品質で安全なコードの開発を改善しています。アランは、「ディア・イーブル・テスター」と「Java フォー・テスター」を含む4冊の本の著者です。また、アランはテクニカル・ウェブ・テストと Java を使った Selenium WebDriver を学ぶのに役立つオンライン・トレーニング・コースも作成しています。アランは SeleniumSimplified.com、EvilTester.com、JavaForTesters.com、CompendiumDev.co.uk にライティングとトレーニングのビデオを投稿しています。

learn more

Secure Code Warriorは、ソフトウェア開発ライフサイクル全体にわたってコードを保護し、サイバーセキュリティを最優先とする文化を築くお手伝いをします。アプリケーションセキュリティマネージャ、開発者、CISO、またはセキュリティ関係者のいずれであっても、安全でないコードに関連するリスクを軽減するお手伝いをします。

デモを予約[ダウンロード]
シェア:
linkedin brandsSocialx logo
リソースハブ

始めるためのリソース

その他の投稿
リソースハブ

始めるためのリソース

その他の投稿