Browse Source

HPCC-14185 Support the option to sign code

Remove the original signing checks now that we do it in lexer.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 năm trước cách đây
mục cha
commit
14f0a549d2

+ 3 - 3
ecl/eclcc/eclcc.cpp

@@ -1325,7 +1325,7 @@ void EclCC::processDefinitions(EclRepositoryArray & repositories)
         }
 
         //Create a repository with just that attribute.
-        Owned<IFileContents> contents = createFileContentsFromText(value, NULL, false);
+        Owned<IFileContents> contents = createFileContentsFromText(value, NULL);
         repositories.append(*createSingleDefinitionEclRepository(module, attr, contents));
     }
 }
@@ -1402,7 +1402,7 @@ void EclCC::processXmlFile(EclCompileInstance & instance, const char *archiveXML
     {
         const char * sourceFilename = archiveTree->queryProp("Query/@originalFilename");
         Owned<ISourcePath> sourcePath = createSourcePath(sourceFilename);
-        contents.setown(createFileContentsFromText(queryText, sourcePath, false));
+        contents.setown(createFileContentsFromText(queryText, sourcePath));
         if (queryAttributePath && queryText && *queryText)
         {
             Owned<IEclSourceCollection> inputFileCollection = createSingleDefinitionEclCollection(queryAttributePath, contents);
@@ -1423,7 +1423,7 @@ void EclCC::processXmlFile(EclCompileInstance & instance, const char *archiveXML
         queryAttributePath = fullPath.str();
 
         //Create a repository with just that attribute, and place it before the archive in the resolution order.
-        Owned<IFileContents> contents = createFileContentsFromText(queryText, NULL, false);
+        Owned<IFileContents> contents = createFileContentsFromText(queryText, NULL);
         repositories.append(*createSingleDefinitionEclRepository(syntaxCheckModule, syntaxCheckAttribute, contents));
     }
 

+ 5 - 5
ecl/hql/hqlcollect.cpp

@@ -289,7 +289,7 @@ bool FileSystemFile::checkValid()
                         version.set(pb.version);
 
                         Owned<ISourcePath> pluginPath = createSourcePath(pb.moduleName);
-                        fileContents.setown(createFileContentsFromText(pb.ECL, pluginPath, false)); // MORE - isSigned
+                        fileContents.setown(createFileContentsFromText(pb.ECL, pluginPath));
 
                         //if (traceMask & PLUGIN_DLL_MODULE)
                         DBGLOG("Loading plugin %s[%s] version = %s", filename, pb.moduleName, version.get());
@@ -665,7 +665,7 @@ IFileContents * CXmlEclElement::queryFileContents()
                 getFullName(defaultName);
                 sourcePath.setown(createSourcePath(defaultName));
             }
-            fileContents.setown(createFileContentsFromText(text, sourcePath, elemTree->getPropBool("@isSigned", false)));
+            fileContents.setown(createFileContentsFromText(text, sourcePath));
         }
     }
     return fileContents;
@@ -799,9 +799,9 @@ IEclSourceCollection * createSingleDefinitionEclCollection(const char * moduleNa
     if (filename)
         attr->setProp("@sourcePath", filename);
 
-    attr->setProp("", contents->getText());
-    if (contents->isSignedModule())
-        attr->setPropBool("@isSigned", true);  // MORE - this is wrong!
+    StringBuffer temp;
+    temp.append(contents->length(), contents->getText());
+    attr->setProp("", temp.str());
     return createArchiveEclCollection(archive);
 }
 

+ 4 - 12
ecl/hql/hqlexpr.cpp

@@ -7538,7 +7538,6 @@ IHqlExpression * createJavadocAnnotation(IHqlExpression * _ownedBody, IPropertyT
 CFileContents::CFileContents(IFile * _file, ISourcePath * _sourcePath) : file(_file), sourcePath(_sourcePath)
 {
     delayedRead = false;
-    isSigned = false;
     if (!preloadFromFile())
         file.clear();
 }
@@ -7610,19 +7609,14 @@ void CFileContents::ensureLoaded()
 
     if (sizeRead != sizeToRead)
         throw MakeStringException(1, "File %s only read %u of %u bytes", file->queryFilename(), sizeRead, sizeToRead);
-    if (strstr(file->queryFilename(), "pipe"))  // TEmporary hack for testing!
-    {
-        DBGLOG("setting signed to true, %p", this);
-        isSigned = true;
-    }
 }
 
-CFileContents::CFileContents(const char *query, ISourcePath * _sourcePath, bool _isSigned)
+CFileContents::CFileContents(const char *query, ISourcePath * _sourcePath) 
 : sourcePath(_sourcePath)
 {
     if (query)
         setContents(strlen(query), query);
-    isSigned = _isSigned;
+
     delayedRead = false;
 }
 
@@ -7631,7 +7625,6 @@ CFileContents::CFileContents(unsigned len, const char *query, ISourcePath * _sou
 {
     setContents(len, query);
     delayedRead = false;
-    isSigned = false;
 }
 
 
@@ -7655,10 +7648,10 @@ IFileContents * createFileContentsFromText(unsigned len, const char * text, ISou
     return new CFileContents(len, text, sourcePath);
 }
 
-IFileContents * createFileContentsFromText(const char * text, ISourcePath * sourcePath, bool isSigned)
+IFileContents * createFileContentsFromText(const char * text, ISourcePath * sourcePath)
 {
     //MORE: Treatment of nulls?
-    return new CFileContents(text, sourcePath, isSigned);
+    return new CFileContents(text, sourcePath);
 }
 
 IFileContents * createFileContentsFromFile(const char * filename, ISourcePath * sourcePath)
@@ -7684,7 +7677,6 @@ public:
     virtual ISourcePath * querySourcePath() { return contents->querySourcePath(); }
     virtual const char *getText() { return contents->getText() + offset; }
     virtual size32_t length() { return len; }
-    virtual bool isSignedModule() { return contents->isSignedModule(); }
 
 protected:
     Linked<IFileContents> contents;

+ 1 - 2
ecl/hql/hqlexpr.hpp

@@ -836,7 +836,6 @@ public:
     virtual ISourcePath * querySourcePath() = 0;
     virtual const char * getText() = 0;
     virtual size32_t length() = 0;
-    virtual bool isSignedModule() = 0;
 };
 
 //This class ensures that the pointer to the owner is cleared before both links are released, which allows
@@ -1841,7 +1840,7 @@ extern HQL_API void extendAdd(SharedHqlExpr & value, IHqlExpression * expr);
 inline bool isOmitted(IHqlExpression * actual) { return !actual || actual->getOperator() == no_omitted; }
 
 extern HQL_API IFileContents * createFileContentsFromText(unsigned len, const char * text, ISourcePath * sourcePath);
-extern HQL_API IFileContents * createFileContentsFromText(const char * text, ISourcePath * sourcePath, bool isSigned);
+extern HQL_API IFileContents * createFileContentsFromText(const char * text, ISourcePath * sourcePath);
 extern HQL_API IFileContents * createFileContentsFromFile(const char * filename, ISourcePath * sourcePath);
 extern HQL_API IFileContents * createFileContentsSubset(IFileContents * contents, size32_t offset, size32_t len);
 extern HQL_API IFileContents * createFileContents(IFile * file, ISourcePath * sourcePath);

+ 2 - 7
ecl/hql/hqlexpr.ipp

@@ -461,11 +461,10 @@ private:
     MemoryAttr fileContents;
     Linked<ISourcePath> sourcePath;
     bool delayedRead;
-    bool isSigned;
 
 public:
     CFileContents(IFile * _file, ISourcePath * _sourcePath);
-    CFileContents(const char *query, ISourcePath * _sourcePath, bool isSigned);
+    CFileContents(const char *query, ISourcePath * _sourcePath);
     CFileContents(unsigned len, const char *query, ISourcePath * _sourcePath);
 
     virtual IFile * queryFile() { return file; }
@@ -481,11 +480,7 @@ public:
         ensureLoaded();
         return fileContents.length()-1;
     }
-    virtual bool isSignedModule()
-    {
-        ensureLoaded();
-        return isSigned;
-    }
+
 private:
     bool preloadFromFile();
     void ensureLoaded();

+ 3 - 3
ecl/hql/hqlgram2.cpp

@@ -342,7 +342,7 @@ HqlGram::HqlGram(IHqlScope * _globalScope, IHqlScope * _containerScope, IFileCon
     moduleName = _containerScope->queryId();
     forceResult = false;
     parsingTemplateAttribute = false;
-    inSignedModule = _text->isSignedModule();
+    inSignedModule = false;
 
     lexObject = new HqlLex(this, _text, xmlScope, NULL);
 
@@ -11596,7 +11596,7 @@ IHqlExpression * reparseTemplateFunction(IHqlExpression * funcdef, IHqlScope *sc
     text.append("=>").append(contents->length(), contents->getText());
 
     //Could use a merge string implementation of IFileContents instead of expanding...
-    Owned<IFileContents> parseContents = createFileContentsFromText(text.str(), contents->querySourcePath(), false);
+    Owned<IFileContents> parseContents = createFileContentsFromText(text.str(), contents->querySourcePath());
     HqlGram parser(scope, scope, parseContents, ctx, NULL, hasFieldMap, true);
     unsigned startLine = funcdef->getStartLine();
 
@@ -11720,7 +11720,7 @@ extern HQL_API IHqlExpression * parseQuery(const char * text, IErrorReceiver * e
 {
     Owned<IHqlScope> scope = createScope();
     HqlDummyLookupContext ctx(errs);
-    Owned<IFileContents> contents = createFileContentsFromText(text, NULL, false);
+    Owned<IFileContents> contents = createFileContentsFromText(text, NULL);
     return parseQuery(scope, contents, ctx, NULL, NULL, true);
 }
 

+ 9 - 9
ecl/hql/hqlparse.cpp

@@ -317,7 +317,7 @@ void HqlLex::pushText(IFileContents * text, int startLineNo, int startColumn)
 
 void HqlLex::pushText(const char *s, int startLineNo, int startColumn)
 {
-    Owned<IFileContents> macroContents = createFileContentsFromText(s, sourcePath, false); // MORE - may be wrong
+    Owned<IFileContents> macroContents = createFileContentsFromText(s, sourcePath);
     pushText(macroContents, startLineNo, startColumn);
 }
 
@@ -327,7 +327,7 @@ void HqlLex::pushText(const char *s)
 #ifdef TIMING_DEBUG
     MTIME_SECTION(timer, "HqlLex::pushText");
 #endif
-    Owned<IFileContents> macroContents = createFileContentsFromText(s, sourcePath, false);  // MORE - may be wrong
+    Owned<IFileContents> macroContents = createFileContentsFromText(s, sourcePath);
     inmacro = new HqlLex(yyParser, macroContents, NULL, NULL);
     inmacro->set_yyLineNo(yyLineNo);
     inmacro->set_yyColumn(yyColumn);
@@ -659,7 +659,7 @@ void HqlLex::processEncrypted()
     decryptEclAttribute(decrypted, encoded64.str());
     decrypted.append(0);    // add a null terminator to the string...
     Owned<ISourcePath> sourcePath = createSourcePath("<encrypted>");
-    Owned<IFileContents> decryptedContents = createFileContentsFromText((const char *)decrypted.toByteArray(), sourcePath, yyParser->inSignedModule);
+    Owned<IFileContents> decryptedContents = createFileContentsFromText((const char *)decrypted.toByteArray(), sourcePath);
     inmacro = new HqlLex(yyParser, decryptedContents, NULL, NULL);
     inmacro->setParentLex(this);
     inmacro->encrypted = true;
@@ -1077,7 +1077,7 @@ void HqlLex::doExport(YYSTYPE & returnToken, bool toXml)
         try
         {
             HqlLookupContext ctx(yyParser->lookupCtx);
-            Owned<IFileContents> exportContents = createFileContentsFromText(curParam.str(), sourcePath, yyParser->inSignedModule);
+            Owned<IFileContents> exportContents = createFileContentsFromText(curParam.str(), sourcePath);
             expr.setown(parseQuery(scope, exportContents, ctx, xmlScope, NULL, true));
 
             if (expr && (expr->getOperator() == no_sizeof))
@@ -1219,8 +1219,8 @@ void HqlLex::doFor(YYSTYPE & returnToken, bool doAll)
 
     forLoop = getSubScopes(returnToken, str(name), doAll);
     if (forFilterText.length())
-        forFilter.setown(createFileContentsFromText(forFilterText, sourcePath, yyParser->inSignedModule));
-    forBody.setown(createFileContentsFromText(forBodyText, sourcePath, yyParser->inSignedModule));
+        forFilter.setown(createFileContentsFromText(forFilterText, sourcePath));
+    forBody.setown(createFileContentsFromText(forBodyText, sourcePath));
 
     loopTimes = 0;
     if (forLoop && forLoop->first()) // more - check filter
@@ -1269,7 +1269,7 @@ void HqlLex::doLoop(YYSTYPE & returnToken)
     ::Release(forLoop);
     forLoop = new CDummyScopeIterator(ensureTopXmlScope());
     forFilter.clear();
-    forBody.setown(createFileContentsFromText(forBodyText, sourcePath, yyParser->inSignedModule));
+    forBody.setown(createFileContentsFromText(forBodyText, sourcePath));
     loopTimes = 0;
     if (forLoop->first()) // more - check filter
         checkNextLoop(returnToken, true,startLine,startCol);
@@ -1510,7 +1510,7 @@ void HqlLex::doIsValid(YYSTYPE & returnToken)
     {
         HqlLookupContext ctx(yyParser->lookupCtx);
         ctx.errs.clear();   //Deliberately ignore any errors
-        Owned<IFileContents> contents = createFileContentsFromText(curParam.str(), sourcePath, yyParser->inSignedModule);
+        Owned<IFileContents> contents = createFileContentsFromText(curParam.str(), sourcePath);
         expr = parseQuery(scope, contents, ctx, xmlScope, NULL, true);
 
         if(expr)
@@ -1788,7 +1788,7 @@ IHqlExpression *HqlLex::parseECL(IFileContents * contents, IXmlScope *xmlScope,
 
 IHqlExpression *HqlLex::parseECL(const char * text, IXmlScope *xmlScope, int startLine, int startCol)
 {
-    Owned<IFileContents> contents = createFileContentsFromText(text, querySourcePath(), yyParser->inSignedModule);
+    Owned<IFileContents> contents = createFileContentsFromText(text, querySourcePath());
     return parseECL(contents, xmlScope, startLine, startCol);
 }
 

+ 1 - 1
ecl/hqlcpp/hqlcpp.cpp

@@ -1390,7 +1390,7 @@ HqlCppTranslator::HqlCppTranslator(IErrorReceiver * _errors, const char * _soNam
             HqlDummyLookupContext ctx(&errs);
             cppSystemScope = createScope();
             Owned<ISourcePath> sysPath = createSourcePath("<system-definitions>");
-            Owned<IFileContents> systemContents = createFileContentsFromText(systemText.str(), sysPath, true);
+            Owned<IFileContents> systemContents = createFileContentsFromText(systemText.str(), sysPath);
             OwnedHqlExpr query = parseQuery(cppSystemScope, systemContents, ctx, NULL, NULL, false);
             if (errs.errCount())
             {