Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

variable PROJECTLCID_Id: expected 0002 but found 004A #3

Closed
neuromancersho opened this issue Mar 14, 2023 · 3 comments · Fixed by #4
Closed

variable PROJECTLCID_Id: expected 0002 but found 004A #3

neuromancersho opened this issue Mar 14, 2023 · 3 comments · Fixed by #4
Labels
bug Something isn't working

Comments

@neuromancersho
Copy link

neuromancersho commented Mar 14, 2023

Pipelineで使わせて頂いたところ、下記のエラーが発生しましたのでご報告させて頂きます。

2023-03-14T04:54:42.2384061Z ##[section]Starting: Extract vba source files.  
2023-03-14T04:54:42.2390928Z ==============================================================================  
2023-03-14T04:54:42.2391155Z Task         : Command line  
2023-03-14T04:54:42.2391263Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows  
2023-03-14T04:54:42.2391453Z Version      : 2.212.0  
2023-03-14T04:54:42.2391559Z Author       : Microsoft Corporation  
2023-03-14T04:54:42.2391696Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line  
2023-03-14T04:54:42.2391893Z ==============================================================================  
2023-03-14T04:54:42.3989317Z Generating script.  
2023-03-14T04:54:42.3998679Z ========================== Starting Command Output ===========================  
2023-03-14T04:54:42.4029166Z [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/2cbf7a2f-fe16-4066-b245-4367a54d8ead.sh  
2023-03-14T04:54:42.4098660Z Specify the location of the Pipfile and run extract_vba_source.py  
2023-03-14T04:54:43.6330998Z Creating a virtualenv for this project...  
2023-03-14T04:54:43.6332144Z Pipfile: /home/vsts/work/1/s/extract_vba_source/Pipfile  
2023-03-14T04:54:43.6555864Z Using /usr/bin/python (3.10.6) to create virtualenv...  
2023-03-14T04:54:44.8351507Z created virtual environment CPython3.10.6.final.0-64 in 777ms  
2023-03-14T04:54:44.8352680Z   creator CPython3Posix(dest=/home/vsts/.local/share/virtualenvs/extract_vba_source--6wonZ3H, clear=False, no_vcs_ignore=False, global=False)  
2023-03-14T04:54:44.8354389Z   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/vsts/.local/share/virtualenv)  
2023-03-14T04:54:44.8355169Z     added seed packages: pip==23.0.1, setuptools==67.4.0, wheel==0.38.4  
2023-03-14T04:54:44.8355841Z   activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator  
2023-03-14T04:54:44.8356306Z   
2023-03-14T04:54:44.8356737Z Successfully created virtual environment!  
2023-03-14T04:54:44.9141764Z Virtualenv location: /home/vsts/.local/share/virtualenvs/extract_vba_source--6wonZ3H  
2023-03-14T04:54:44.9142740Z Pipfile.lock not found, creating...  
2023-03-14T04:54:44.9331932Z Locking [packages] dependencies...  
2023-03-14T04:54:44.9528647Z Building requirements...  
2023-03-14T04:54:44.9594800Z Resolving dependencies...  
2023-03-14T04:54:51.3528976Z Success!  
2023-03-14T04:54:51.3609034Z Locking [dev-packages] dependencies...  
2023-03-14T04:54:51.3664060Z Updated Pipfile.lock (59a35ca32ef930ef4ce92e0c23814e936228eb3bdb7fc82011d27583eb11f1ff)!  
2023-03-14T04:54:51.3704797Z Installing dependencies from Pipfile.lock (11f1ff)...  
2023-03-14T04:54:56.2170305Z To activate this project's virtualenv, run pipenv shell.  
2023-03-14T04:54:56.2171214Z Alternatively, run a command inside the virtualenv with pipenv run.  
2023-03-14T04:54:57.1362350Z Extract vba files from /home/vsts/work/1/s/M221_001_wk.xlsm to vba-src/M221_001_wk  
2023-03-14T04:54:57.1363388Z Traceback (most recent call last):  
2023-03-14T04:54:57.1363947Z   File "/home/vsts/work/1/s/./extract_vba_source/extract_vba_source.py", line 96, in <module>  
2023-03-14T04:54:57.1365804Z     for vba_filename, vba_code in extract_macros(vba_parser, args.src_encoding):  
2023-03-14T04:54:57.1366602Z   File "/home/vsts/work/1/s/./extract_vba_source/extract_vba_source.py", line 62, in extract_macros  
2023-03-14T04:54:57.1367129Z     for results in extract_macros(subfile, vba_encoding):  
2023-03-14T04:54:57.1369671Z   File "/home/vsts/work/1/s/./extract_vba_source/extract_vba_source.py", line 67, in extract_macros  
2023-03-14T04:54:57.1370362Z     project = VBA_Project(parser.ole_file, vba_root, project_path, dir_path, relaxed=False)  
2023-03-14T04:54:57.1371200Z   File "/home/vsts/.local/share/virtualenvs/extract_vba_source--6wonZ3H/lib/python3.10/site-packages/oletools/olevba.py", line 1707, in __init__  
2023-03-14T04:54:57.1372198Z     self.check_value('PROJECTLCID_Id', 0x0002, projectlcid_id)  
2023-03-14T04:54:57.1376033Z   File "/home/vsts/.local/share/virtualenvs/extract_vba_source--6wonZ3H/lib/python3.10/site-packages/oletools/olevba.py", line 1991, in check_value  
2023-03-14T04:54:57.1378013Z     raise UnexpectedDataError(self.dir_path, name, expected, value)  
2023-03-14T04:54:57.1378808Z oletools.olevba.UnexpectedDataError: Unexpected value in VBA/dir for variable PROJECTLCID_Id: expected 0002 but found 004A!  
2023-03-14T04:54:57.2573709Z ##[error]Bash exited with code '1'.  
2023-03-14T04:54:57.2622770Z ##[section]Finishing: Extract vba source files.

内容から、decalage2さんのこのコード
https://github.com/decalage2/oletools/blob/master/oletools/olevba.py

        projectlcid_id = struct.unpack("<H", dir_stream.read(2))[0]  
        self.check_value('PROJECTLCID_Id', 0x0002, projectlcid_id)  

0x0002 のところが 0x004A でなければならないので、takerukoさんに報告するのは筋違いかと思いますが、ご報告です。

yamlやextract_vba_source.pyを自分で改造してみたりしましたが、私の技量では足りませんでした。
Pipelineがソースを持ってくる仕組みやgithubのお作法なども全くわかっていません。すみません。

@neuromancersho
Copy link
Author

環境を書いていませんでした。
Microsoft® Excel® for Microsoft 365 MSO (バージョン 2202 ビルド 16.0.14931.20648) 32 ビット
でxlsmファイルとして保存したもの。
Azure DevOpsを企業で契約して使っています。

@takeruko takeruko added the bug Something isn't working label Mar 14, 2023
@takeruko
Copy link
Owner

@neuromancersho さん
ご報告ありがとうございます。

0x0002 のところが 0x004A でなければならないので、takerukoさんに報告するのは筋違いかと思いますが、ご報告です。
この件、oletoolsでもissueとして挙がってますね。

よくよく調べたら、xlsmファイルのproject_idが0x004Aに変更されててエラーになるというのは2021年くらいから報告されていたみたいで、
すでにPull Requestも挙がっているみたい。

上記Pull Requestされているoletoolsのforkを使うとエラーが解消されることが確認できたので、こいつをpip installする暫定対応を入れました。

再度Piplelineを実行すればエラー解消されると思うので試してみてください。

@neuromancersho
Copy link
Author

再実行しただけで成功しました。
かなり捗ります。
ありがとうございます。

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants