Skip to content

Commit 768ca0b

Browse files
committed
Catch bad module names in the Yang checker (they are not currently flagged by xym).
- Legacy-Id: 13700
1 parent 95f966c commit 768ca0b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ietf/submit/checkers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright The IETF Trust 2016, All Rights Reserved
2+
from __future__ import unicode_literals, print_function
23

34
import os
45
import re
@@ -124,11 +125,12 @@ def check_file_txt(self, path):
124125
class DraftYangChecker(object):
125126

126127
name = "yang validation"
127-
symbol = u'<span class="large">\u262f</span>'
128+
symbol = '<span class="large">\u262f</span>'
128129

129130
def check_file_txt(self, path):
130131
name = os.path.basename(path)
131132
workdir = tempfile.mkdtemp()
133+
model_name_re = r'^[A-Za-z_][A-Za-z0-9_.-]*(@\d\d\d\d-\d\d-\d\d)?\.yang$'
132134
errors = 0
133135
warnings = 0
134136
message = ""
@@ -161,11 +163,16 @@ def check_file_txt(self, path):
161163
# Found no yang modules, don't deliver any YangChecker result
162164
return None, "", 0, 0, []
163165

166+
for n in model_list:
167+
if not re.search(model_name_re, n):
168+
debug.debug = True
169+
code += 1
170+
err += "Error: Bad extracted model name: '%s'\n" % n
171+
164172
command = "xym"
165173
cmd_version = VersionInfo.objects.get(command=command).version
166174
message = "%s:\n%s\n\n" % (cmd_version, out.replace('\n\n','\n').strip() if code == 0 else err)
167175

168-
169176
results.append({
170177
"name": name,
171178
"passed": passed,

0 commit comments

Comments
 (0)