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

new tidy_docs checks #13188

Merged
merged 2 commits into from
Apr 6, 2020
Merged
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
18 changes: 18 additions & 0 deletions tools/dev/msftidy_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def h2_order
def line_checks
idx = 0
in_codeblock = false
in_options = false

@lines.each do |ln|
idx += 1
Expand All @@ -218,6 +219,23 @@ def line_checks
in_codeblock = !in_codeblock
end

if ln =~ /## Options/
in_options = true
end

if ln =~ /## Scenarios/ || (in_options && ln =~ /$\s*## /) # we're not in options anymore
# we set a hard false here because there isn't a guarantee options exists
in_options = false
end

if in_options && ln =~ /^\s*\*\*[a-z]+\*\*$/i # catch options in old format like **command** instead of ### comand
warn("Options should use ### instead of bolds (**)", idx)
end

# this will catch either bold or h2/3 universal options. Defaults aren't needed since they're not unique to this exploit
if in_options && ln =~ /^\s*[\*#]{2,3}\s*(rhost|rhosts|rport|lport|lhost|srvhost|srvport|ssl|uripath|session|proxies|payload)\*{0,2}$/i
warn('Universal options such as rhost(s), rport, lport, lhost, srvhost, srvport, ssl, uripath, session, proxies, payload can be removed.', idx)
end
# find spaces at EOL not in a code block which is ``` or starts with four spaces
if !in_codeblock && ln =~ /[ \t]$/ && !(ln =~ /^ /)
warn("Spaces at EOL", idx)
Expand Down