Skip to content

Commit bbd3d4f

Browse files
authored
Merge pull request #9579 from dgarske/coding_standard_20251223
Add new coding standard for local (internal) function names
2 parents 7765128 + d39b0e6 commit bbd3d4f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

devin_lifeguard.yaml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
rules:
22
- name: no-void-functions
33
trigger: >-
4-
All functions must return a value. Avoid using void return types to ensure
5-
error values can be propagated upstream.
4+
When implementing new public functions (WOLFSSL_API) avoid using "void"
5+
return type to ensure error values can be propagated upstream. Does not
6+
apply to "doc/" directory.
67
solution: >-
78
Change the function to return an appropriate error code or result instead
89
of void. Ensure all return paths provide a meaningful value.
@@ -51,12 +52,17 @@ rules:
5152
variables to minimize stack usage within the function.
5253
- name: prefer-constant-time
5354
trigger: >-
54-
Implement algorithms in constant time to prevent timing attacks and ensure
55-
security.
56-
solution: >-
57-
Review and refactor algorithms to ensure their execution time does not
58-
depend on input values. Use constant-time libraries or functions where
59-
applicable.
55+
Any code handling secret or private key data (symmetric or asymmetric)
56+
must be implemented in constant time. This includes cryptographic
57+
operations, key comparisons, and encoding/decoding operations (base64,
58+
hex, etc.) when processing secrets. Use constant-time implementations
59+
by default for all secret data since tracking when timing attacks are
60+
strictly possible is error-prone.
61+
solution: >-
62+
Review and refactor code to ensure execution time does not depend on
63+
secret values. Use constant-time functions such as ConstantCompare()
64+
for comparisons and avoid early-exit conditions based on secret data.
65+
When in doubt, assume constant-time handling is required.
6066
- name: use-sizeof
6167
trigger: >-
6268
Avoid hard-coded numeric values for sizes. Use `sizeof()` to ensure
@@ -143,3 +149,13 @@ rules:
143149
144150
ensure ephemeral structures are freed once no longer needed, and avoid
145151
reusing pointers after free
152+
- name: use-proper-function-visibility
153+
trigger: >-
154+
functions must use appropriate visibility modifiers. Public functions
155+
should use WOLFSSL_API, local functions should use WOLFSSL_LOCAL, and
156+
non-static local functions should have a wolfssl_local_ or wc_local_ prefix.
157+
solution: >-
158+
for public functions that are part of the external API, declare them with
159+
WOLFSSL_API. For functions local to the library but not static, use
160+
WOLFSSL_LOCAL and prefix the function name with wolfssl_local_ or wc_local_
161+
to clearly indicate internal usage.

0 commit comments

Comments
 (0)