summaryrefslogtreecommitdiff
path: root/.astgrep/rules/blocking-functions.yml
blob: 2faacc8c281979a7ee11b6d076253add985790bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# SPDX-License-Identifier: Apache-2.0
# Common Error #6: Blocking functions
# Machine-enforceable rules for patterns documented in docs/COMMON_ERRORS.md.

id: bmcweb.common-errors.blocking-call-sleep
language: cpp
severity: error
message: >
    Avoid blocking sleep calls in bmcweb reactor paths. Use async timers or
    callback-driven flow per docs/COMMON_ERRORS.md.
rule:
    any:
        - pattern: sleep($$$)
        - pattern: usleep($$$)
        - pattern: nanosleep($$$)
---
id: bmcweb.common-errors.blocking-call-sync-socket-api
language: cpp
severity: error
message: >
    Avoid blocking socket APIs in bmcweb request paths. Use async APIs per
    docs/COMMON_ERRORS.md.
rule:
    any:
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::read($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::read_some($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::write($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::write_some($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::connect($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::send($$$);"
              selector: call_expression
        - pattern:
              context: "auto x = boost::asio::ip::tcp::socket::wait($$$);"
              selector: call_expression
---
id: bmcweb.common-errors.blocking-call-sync-timer-wait
language: cpp
severity: error
message: >
    Avoid blocking timer wait calls in bmcweb request paths. Use async_wait per
    docs/COMMON_ERRORS.md.
rule:
    pattern:
        context: "auto x = boost::asio::steady_timer::wait($$$);"
        selector: call_expression