Skip to content

Commit f4f2643

Browse files
markdownlint: fix all warnings
Signed-off-by: Patrick Williams <[email protected]> Change-Id: I1402cbd84c916792ca2fc0ad0f34db661cbdfa72
1 parent dfa3fdc commit f4f2643

13 files changed

+353
-349
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assignees: ""
1212
QEMU, please add
1313

1414
What specific OpenBMC versions (SHA1) did you use? (note, SHA1 should be
15-
resolvable to https://github.com/openbmc/openbmc)
15+
resolvable to <https://github.com/openbmc/openbmc>)
1616

1717
**To Reproduce** Steps to reproduce the behavior:
1818

.github/ISSUE_TEMPLATE/custom.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ assignees: ""
99
Please do not use GitHub issues for submitting questions. Please submit your
1010
questions either to the OpenBMC mailing list, or to the OpenBMC discord channel.
1111

12-
https://github.com/openbmc/docs/blob/master/README.md#contact
12+
<https://github.com/openbmc/docs/blob/master/README.md#contact>

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ assignees: ""
88

99
Please do not submit feature requests to GitHub. Please indicate your interest
1010
in particular projects or features on the mailing list at
11-
https://lists.ozlabs.org/listinfo/openbmc
11+
<https://lists.ozlabs.org/listinfo/openbmc>

.markdownlint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
default: true
2+
MD024:
3+
siblings_only: true

CLIENTS.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Client overview
2+
13
bmcweb being a user and network facing daemon, is subject to a vast array of
24
tests and clients that could target it. The below attempts to provide a
35
non-exhaustive list of tests and clients that bmcweb is expected to be
@@ -31,13 +33,13 @@ portion of the OpenBMC Redfish use cases.
3133
Status: Passing for some machines with CI integration.
3234

3335
slowloris: A tool to verify timeouts and DOS attack mitigation is implemented
34-
properly. https://github.com/gkbrk/slowloris
36+
properly. <https://github.com/gkbrk/slowloris>
3537

3638
Status: Passing, no automated enforcement.
3739

3840
testssl.sh: A tool for verifying the corectness of the bmcweb cipher suites
3941
against current recommended security standards
40-
https://github.com/drwetter/testssl.sh
42+
<https://github.com/drwetter/testssl.sh>
4143

4244
Status: Unknown
4345

@@ -55,7 +57,7 @@ [email protected]:DMTF/python-redfish-library.git
5557
Status: Compatible
5658

5759
Redfish-Event-Listener: An example client for testing and implementing
58-
EventService handlers. https://github.com/DMTF/Redfish-Event-Listener
60+
EventService handlers. <https://github.com/DMTF/Redfish-Event-Listener>
5961

6062
Status: Compatible. No CI integration.
6163

@@ -65,6 +67,6 @@ [email protected]:DMTF/Redfish-Tacklebox.git
6567
Status: Unknown.
6668

6769
redfishtool: A generic command line tool for reading and writing operations to
68-
the Redfish server. https://github.com/DMTF/Redfishtool
70+
the Redfish server. <https://github.com/DMTF/Redfishtool>
6971

7072
Status: Compatible. No automated testing.

COMMON_ERRORS.md

+41-40
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ not-always-obvious ways, or impose a pattern that tends to cause hard to find
99
bugs, or bugs that appear later. Every one has been submitted to code review
1010
multiple times.
1111

12-
### 1. Directly dereferencing a pointer without checking for validity first
12+
## 1. Directly dereferencing a pointer without checking for validity first
1313

14-
```C++
14+
```cpp
1515
int myBadMethod(const nlohmann::json& j){
1616
const int* myPtr = j.get_if<int>();
1717
return *myPtr;
@@ -20,34 +20,34 @@ int myBadMethod(const nlohmann::json& j){
2020
2121
This pointer is not guaranteed to be filled, and could be a null dereference.
2222
23-
### 2. String views aren't null terminated
23+
## 2. String views aren't null terminated
2424
25-
```C++
25+
```cpp
2626
int getIntFromString(const std::string_view s){
2727
return std::atoi(s.data());
2828
}
2929
```
3030

3131
This will give the right answer much of the time, but has the possibility to
32-
fail when string_view is not null terminated. Use from_chars instead, which
32+
fail when `string_view` is not null terminated. Use `from_chars` instead, which
3333
takes both a pointer and a length
3434

35-
### 3. Not handling input errors
35+
## 3. Not handling input errors
3636

37-
```C++
37+
```cpp
3838
int getIntFromString(const std::string& s){
3939
return std::atoi(s.c_str());
4040
}
4141
```
4242
4343
In the case where the string is not representable as an int, this will trigger
4444
undefined behavior at system level. Code needs to check for validity of the
45-
string, ideally with something like from_chars, and return the appropriate error
46-
code.
45+
string, ideally with something like `from_chars`, and return the appropriate
46+
error code.
4747
48-
### 4. Walking off the end of a string
48+
## 4. Walking off the end of a string
4949
50-
```C++
50+
```cpp
5151
std::string getFilenameFromPath(const std::string& path){
5252
size_t index = path.find("/");
5353
if (index != std::string::npos){
@@ -58,9 +58,9 @@ std::string getFilenameFromPath(const std::string& path){
5858
}
5959
```
6060

61-
### 5. Using methods that throw (or not handling bad inputs)
61+
## 5. Using methods that throw (or not handling bad inputs)
6262

63-
```C++
63+
```cpp
6464
int myBadMethod(nlohmann::json& j){
6565
return j.get<int>();
6666
}
@@ -90,7 +90,7 @@ Commonly used methods that fall into this pattern:
9090
- std::stol
9191
- std::stoll
9292
93-
#### Special note: JSON
93+
### Special note: JSON
9494
9595
`nlohmann::json::parse` by default
9696
[throws](https://json.nlohmann.me/api/basic_json/parse/) on failure, but also
@@ -103,7 +103,7 @@ accepts an optional argument that causes it to not throw: set the 4th argument
103103
to `replace`. Although `ignore` preserves content 1:1, `replace` is preferred
104104
from a security point of view.
105105
106-
#### Special note: Boost
106+
### Special note: Boost
107107
108108
there is a whole class of boost asio functions that provide both a method that
109109
throws on failure, and a method that accepts and returns an error code. This is
@@ -116,7 +116,7 @@ asio methods, and prefer the one that returns an error code instead of throwing.
116116
- boost::asio::ip::tcp::acceptor::listen();
117117
- boost::asio::ip::address::make_address();
118118
119-
### 6. Blocking functions
119+
## 6. Blocking functions
120120
121121
bmcweb uses a single reactor for all operations. Blocking that reactor for any
122122
amount of time causes all other operations to stop. The common blocking
@@ -138,15 +138,15 @@ system, the fact that most filesystem accesses are into tmpfs (and therefore
138138
should be "fast" most of the time) and in general how little the filesystem is
139139
used in practice.
140140
141-
### 7. Lack of locking between subsequent calls
141+
## 7. Lack of locking between subsequent calls
142142
143143
While global data structures are discouraged, they are sometimes required to
144144
store temporary state for operations that require it. Given the single threaded
145145
nature of bmcweb, they are not required to be explicitly threadsafe, but they
146146
must be always left in a valid state, and checked for other uses before
147147
occupying.
148148
149-
```C++
149+
```cpp
150150
std::optional<std::string> currentOperation;
151151
void firstCallbackInFlow(){
152152
currentOperation = "Foo";
@@ -159,9 +159,9 @@ void secondCallbackInFlow(){
159159
In the above case, the first callback needs a check to ensure that
160160
currentOperation is not already being used.
161161

162-
### 8. Wildcard reference captures in lambdas
162+
## 8. Wildcard reference captures in lambdas
163163

164-
```
164+
```cpp
165165
std::string x; auto mylambda = [&](){
166166
x = "foo";
167167
}
@@ -173,11 +173,12 @@ async bmcweb code. While capturing by reference can be useful, given how
173173
difficult these types of bugs are to triage, bmcweb explicitly requires that all
174174
code captures variables by name explicitly, and calls out each variable being
175175
captured by value or by reference. The above prototypes would change to
176-
[&x]()... Which makes clear that x is captured, and its lifetime needs tracked.
176+
`[&x]()...` Which makes clear that x is captured, and its lifetime needs
177+
tracked.
177178
178-
### 9. URLs should end in "/"
179+
## 9. URLs should end in "/"
179180
180-
```C++
181+
```cpp
181182
BMCWEB("/foo/bar");
182183
```
183184

@@ -188,9 +189,9 @@ the route ending in slash and the one without. This allows both URLs to be used
188189
by users. While many specifications do not require this, it resolves a whole
189190
class of bug that we've seen in the past.
190191

191-
### 10. URLs constructed in aggregate
192+
## 10. URLs constructed in aggregate
192193

193-
```C++
194+
```cpp
194195
std::string routeStart = "/redfish/v1";
195196

196197
BMCWEB_ROUTE(routestart + "/SessionService/")
@@ -203,9 +204,9 @@ by a simple grep statement to search for urls in question. Doing the above makes
203204
the route handlers no longer greppable, and complicates bmcweb patchsets as a
204205
whole.
205206
206-
### 11. Not responding to 404
207+
## 11. Not responding to 404
207208
208-
```C++
209+
```cpp
209210
BMCWEB_ROUTE("/myendpoint/<str>",
210211
[](Request& req, Response& res, const std::string& id){
211212
crow::connections::systemBus->async_method_call(
@@ -228,16 +229,16 @@ All bmcweb routes should handle 404 (not found) properly, and return it where
228229
appropriate. 500 internal error is not a substitute for this, and should be only
229230
used if there isn't a more appropriate error code that can be returned. This is
230231
important, because a number of vulnerability scanners attempt injection attacks
231-
in the form of /myendpoint/foobar, or /myendpoint/#$*(%)&#%$)(\*& in an attempt
232-
to circumvent security. If the server returns 500 to any of these requests, the
233-
security scanner logs it as an error for followup. While in general these errors
234-
are benign, and not actually a real security threat, having a clean security run
235-
allows maintainers to minimize the amount of time spent triaging issues reported
236-
from these scanning tools.
232+
in the form of `/myendpoint/foobar`, or `/myendpoint/#$*(%)&#%$)(\*&` in an
233+
attempt to circumvent security. If the server returns 500 to any of these
234+
requests, the security scanner logs it as an error for followup. While in
235+
general these errors are benign, and not actually a real security threat, having
236+
a clean security run allows maintainers to minimize the amount of time spent
237+
triaging issues reported from these scanning tools.
237238

238239
An implementation of the above that handles 404 would look like:
239240

240-
```C++
241+
```cpp
241242
BMCWEB_ROUTE("/myendpoint/<str>",
242243
[](Request& req, Response& res, const std::string& id){
243244
crow::connections::systemBus->async_method_call(
@@ -265,9 +266,9 @@ on a working system, and any cases where 500 is found, can immediately be
265266
assumed to be
266267
[a bug in either the system, or bmcweb.](https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#error-handling)
267268
268-
### 12. Imprecise matching
269+
## 12. Imprecise matching
269270
270-
```C++
271+
```cpp
271272
void isInventoryPath(const std::string& path){
272273
if (path.find("inventory")){
273274
return true;
@@ -281,7 +282,7 @@ avoid doing direct string containment matching. Doing so can lead to errors
281282
where fan1 and fan11 both report to the same object, and cause behavior breaks
282283
in subtle ways.
283284

284-
When using dbus paths, rely on the methods on sdbusplus::message::object_path.
285+
When using dbus paths, rely on the methods on `sdbusplus::message::object_path`.
285286
When parsing HTTP field and lists, use the RFC7230 implementations from
286287
boost::beast.
287288

@@ -300,9 +301,9 @@ The above methods tend to be misused to accept user data and parse various
300301
fields from it. In practice, there tends to be better, purpose built methods for
301302
removing just the field you need.
302303

303-
### 13. Complete replacement of the response object
304+
## 13. Complete replacement of the response object
304305

305-
```
306+
```cpp
306307
void getMembers(crow::Response& res){
307308
res.jsonValue = {{"Value", 2}};
308309
}
@@ -314,7 +315,7 @@ Completely replacing the json object can lead to convoluted situations where the
314315
output of the response is dependent on the _order_ of the asynchronous actions
315316
completing, which cannot be guaranteed, and has many time caused bugs.
316317
317-
```
318+
```cpp
318319
void getMembers(crow::Response& res){
319320
res.jsonValue["Value"] = 2;
320321
}

DBUS_USAGE.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# dbus usage
2+
13
The following are guidelines for bmcweb's use of DBus to construct Redfish
24
schemas:
35

0 commit comments

Comments
 (0)