Checking for an non-standard section name
496915
def check_nonstandard_section_name(self):
        '''  '''
        std_sections = ['.text', '.bss', '.rdata', '.data', '.rsrc', '.edata', '.idata',
                        '.pdata', '.debug', '.reloc', '.stab', '.stabstr', '.tls',
                        '.crt', '.gnu_deb', '.eh_fram', '.exptbl', '.rodata']
        for i in range(200):
            std_sections.append('/'+str(i))
        non_std_sections = []
        for section in self.pefile_handle.sections:
            name = convert_to_ascii_null_term(section.Name).lower()
            if (name not in std_sections):
                non_std_sections.append(name)
        if non_std_sections:
            return{'description': 'Section(s) with a non-standard name, tamper indication', 
                   'severity': 3, 'category': 'MALFORMED', 'attributes': non_std_sections}

        return None
1225586
def nonver_name(self):
        """"""
        nv = self.as_version(None)
        if not nv:
            import re
            nv = re.sub(r'-[^-]+$', '', self.name)

        return nv
1233509
def section_names(self, ordkey="wall_time"):
        
        section_names = []

        # FIXME this is not trivial
        for idx, timer in enumerate(self.timers()):
            if idx == 0:
                section_names = [s.name for s in timer.order_sections(ordkey)]
                #check = section_names
                #else:
                #  new_set = set( [s.name for s in timer.order_sections(ordkey)])
                #  section_names.intersection_update(new_set)
                #  check = check.union(new_set)

        #if check != section_names:
        #  print("sections", section_names)
        #  print("check",check)

        return section_names
1141767
def check_module_name(self, name, offset=0):
        
        if name in ["general"]:
            return
        split_name = name.split()
        if len(split_name) > 1 and split_name[0] in I3S_SINGLE_NAMES:
            self.current_token -= len(split_name) - 1 - offset
            self.error("Invalid name cannot have 2 tokens")
        if len(split_name) > 2:
            self.current_token -= len(split_name) - 2 - offset
            self.error("Invalid name cannot have more than 2 tokens")
439967
def raw_name(self):
        """"""
        parts = self.raw_parts
        if self.is_absolute():
            parts = parts[1:]
            if not parts:
                return ""
            else:
                return parts[-1]
        else:
            return parts[-1]
874769
boolean checkName(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx) {
        assert paramNewRtx != null;
        assert paramOldRtx != null;
        boolean found = false;
        if (paramNewRtx.getNode().getKind() == paramOldRtx.getNode().getKind()) {
            switch (paramNewRtx.getNode().getKind()) {
            case ELEMENT:
                if (paramNewRtx.getQNameOfCurrentNode().equals(paramOldRtx.getQNameOfCurrentNode())) {
                    found = true;
                }
                break;
            case TEXT:
                if (paramNewRtx.getValueOfCurrentNode().equals(paramOldRtx.getValueOfCurrentNode())) {
                    found = true;
                }
                break;
            default:
            }
        }
        return found;
    }
1220738
private boolean matchesQualifiedName(String qname, int endIndex) {
    int start = qname.lastIndexOf('.', endIndex - 1) + 1;

    switch (this.getToken()) {
      case NAME:
        String name = getString();
        return start == 0 && !name.isEmpty() && name.length() == endIndex && qname.startsWith(name);
      case THIS:
        return start == 0 && 4 == endIndex && qname.startsWith("this");
      case SUPER:
        return start == 0 && 5 == endIndex && qname.startsWith("super");
      case GETPROP:
        String prop = getLastChild().getString();
        return start > 1
            && prop.length() == endIndex - start
            && prop.regionMatches(0, qname, start, endIndex - start)
            && getFirstChild().matchesQualifiedName(qname, start - 1);

      case MEMBER_FUNCTION_DEF:
        // These are explicitly *not* qualified name components.
      default:
        return false;
    }
  }
775431
function getSectionName(article) {
  const { tiles } = article;

  if (!tiles) {
    return null;
  }

  const slices = tiles.reduce((acc, tile) => {
    acc.push(...tile.slices);
    return acc;
  }, []);
  const sections = slices.reduce((acc, slice) => {
    acc.push(...slice.sections);
    return acc;
  }, []);
  const titles = sections.map(section => section.title);

  if (titles.length === 0) {
    return null;
  }

  const nonNews = titles.filter(title => title !== "News");

  return nonNews.length ? nonNews[0] : "News";
}
635725
def prt_section_key(self, prt=sys.stdout):
        """"""
        for section_name, letter in self.sec2chr.items():
            prt.write("{ABC} {SEC_NAME}\n".format(ABC=letter, SEC_NAME=section_name))
945197
void expectValidTypeofName(Node n, String found) {
    report(JSError.make(n, UNKNOWN_TYPEOF_VALUE, found));
  }
171962
def __StripName(self, name):
        """"""
        if not name:
            return name
        for prefix in self.__strip_prefixes:
            if name.startswith(prefix):
                return name[len(prefix):]
        return name
188414
def _check_names_match(data_names, data_shapes, name, throw):
    """"""
    actual = [x[0] for x in data_shapes]
    if sorted(data_names) != sorted(actual):
        msg = "Data provided by %s_shapes don't match names specified by %s_names (%s vs. %s)"%(
            name, name, str(data_shapes), str(data_names))
        if throw:
            raise ValueError(msg)
        else:
            warnings.warn(msg)
877675
def check_var_standard_name(self, ds):
        '''
        
        '''
        results = []
        for variable in self.get_applicable_variables(ds):
            msgs = []
            std_name = getattr(ds.variables[variable], 'standard_name', None)
            check = std_name is not None
            if not check:
                msgs.append("standard_name")
            results.append(Result(BaseCheck.HIGH, check, self._var_header.format(variable), msgs))

        return results
183834
def which(self, fname):
        """"""
        for pe in os.environ['PATH'].split(os.pathsep):
            checkname = os.path.join(pe, fname)
            if os.access(checkname, os.X_OK) and not os.path.isdir(checkname):
                return checkname
        return None
482331
def name_check(self, original, loc, tokens):
        """"""
        internal_assert(len(tokens) == 1, "invalid name tokens", tokens)
        if self.strict:
            self.unused_imports.discard(tokens[0])
        if tokens[0] == "exec":
            return self.check_py("3", "exec function", original, loc, tokens)
        elif tokens[0].startswith(reserved_prefix):
            raise self.make_err(CoconutSyntaxError, "variable names cannot start with reserved prefix " + reserved_prefix, original, loc)
        else:
            return tokens[0]
969003
def _find_sections(self, name_type_pairs):
        """"""
        sections = [None] * len(name_type_pairs)
        for section in self.elf.sections:
            section_name = to_str_safe(section.name)
            section_type = section.type
            for i, name_and_type in enumerate(name_type_pairs):
                if name_and_type != (section_name, section_type):
                    continue
                if sections[i] is not None:
                    raise FlashAlgoException("Elf contains duplicate section %s attr %s" %
                                    (section_name, section_type))
                sections[i] = section
        return sections
822835
def l_sa_check(template, literal, is_standalone):
    """"""

    # If there is a newline, or the previous tag was a standalone
    if literal.find('\n') != -1 or is_standalone:
        padding = literal.split('\n')[-1]

        # If all the characters since the last newline are spaces
        if padding.isspace() or padding == '':
            # Then the next tag could be a standalone
            return True
        else:
            # Otherwise it can't be
            return False