Skip to main content

Querying GitHub Issues from Google App Script

I'm currently exploring different integrations that can be done between Google App Script and Git. This is part of a bigger attempt to integrate Git data into my project management system. I'll post more on that later. GitHub supports a number of very nice sub-systems. One of them is the GitHub Issues ticket tracking system. It's fairly robust and comes with GitHub - which means it's highly integrated out-of-the-box. Integration with Google's App Script is done via the fetchURL command and JSON object manipulation.  After a good bit of experimentation, I've settled on querying GitHub Issues with an "on open spreadsheet event" to avoid issues with Google's quota system. Essentially, Google prevents you from calling the fetchURL command more than X times (see the quota limits ) per day. That's not great if you have people actively working and changing data in a spreadsheet. Some of my other App Script routines are running thousands of times per d...

Vista UAC Manifest

Here's a couple of interesting little tidbits for those using Delphi 2007 and trying to create manifest files to require your program to run as Administrator. For those who don't know what this means, we're talking about running a program and receiving the wonderful little pop-up "A program is trying to take over your life"... well, something like that anyway. You will need your program to receive elevated privileges if you want to do certain things. In my particular instance, I wanted to write to the HKEY_CLASSES_ROOT registry entries. This isn't supposed to be a full reference to what a manifest is, how it works, etc., etc. Microsoft has documented the UAC in some depth and I recommend using their documentation if you want to really understand your options.

First, the manifest structure is basically just an XML document that tells Vista how it should handle the program. For elevated privileges, it should look like:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity version="1.0.0.0" processorarchitecture="X86" name="Vista UAC Compat.Application" type="win32">
<description>WindowsVistaReadiness Application</description>
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator">
</requestedexecutionlevel>
</requestedprivileges>
</security>
</trustinfo>


(thanks to Henrik Bruhn who helpfully posted the above manifest on borland.public.delphi.non-technical)

Second, D2007 automatically includes a manifest file. If you manually create a manifest file, you wind up with two manifests attached to your program. This will actually create a DCC32 error when you go to compile (duplicate resource). In order to fix this, you have to disable run-time themes under Project/Options/Application. Of course, you then become responsible for inserting the appropriate ComCtrl32 language into the manifest to "upgrade" to the themed ComCtrl32 library that became available in Windows XP. Don't ask me why CodeGear didn't give a little check box to enable this feature. It may have something to do with my fifth point below. At any rate, the updated manifest file (merged with what D2007 automatically includes) looks like:


<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity type="win32" name="CodeGear RAD Studio" version="11.0.2804.9245" processorarchitecture="*">
<dependency>
<dependentassembly>
<assemblyidentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publickeytoken="6595b64144ccf1df" language="*" processorarchitecture="*">
</assemblyidentity>
</dependentassembly>
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator" uiaccess="false">
</requestedexecutionlevel>
</requestedprivileges>
</security>
</trustinfo>


Note that the information in the assemblyIdentity can be changed to match your information instead of just blindly copying D2007's information.

Third, you have to include the manifest in your dpr. Make sure you've saved the XML from above as some known file name (vista.manifest in my case). To do this, you will need to create an RC and RES files. D2007 makes this fairly straight-forward. You don't even have to fool with brcc32 anymore. Just create a blank text file and insert


1 24 vista.manifest


in the file. Save that as vistaprog.rc (do not name it the same as either your project or any file in your project, this will cause a resource file conflict.) In your dpr, underneath the


{$R *.res}

add a new line


{$R 'vistaprog.res' 'vistaprog.rc'}

Now, when you do your build, D2007 will automatically compile the RC file, include the vista.manifest and generate a RES file which will be linked into the EXE.

Fourth, you cannot run your program from a substituted (using the subst command) drive. This is probably a minor annoyance for most since subst is used by command line junkies more than anyone else. In my specific case, I have a set of code paths representing versions (i.e., c:\source\v1, c:\source\v2, c:\source\v3) and I use subst to create a working environment that the IDE works with but is totally transparent to which version I'm in. For instance, subst j: c:\source\v? where ? represents the source code version I want to work. This provides a drive letter (j:) that is anchored to that directory. If you do try to run the program from a substed drive, you will see that you get a message "The specified path does not exist. Check the path and try again." If you ran it from the console, you receive the same error message AND a command line message saying "The system cannot find the file xxxx." It works fine if you just move the exe to a normal drive.

There may be a fifth issue, I haven't quite decided on this one yet. I am currently unable to run an elevated program in D2007. I suspect this is because Vista starts the exe, sees the manifest, terminates the exe and restarts it under the new security level. Obviously, this is not going to make the Delphi debugger very happy. I'm still researching this particular aspect of it. If this is truly what is happening, it should make debugging elevated programs a lot of fun.

If you are interested in some other articles on the manifest system, look here, the original thread from Henrick on the newsgroup, here for Steve Trefethen talking about the automatic inclusion of manifest info in D2007, here on the XP manifest, here for a discussion on Windows XP manifest and ComCtrl32, and here for a detailed discussion on UAC. The last link I provided offers a COM factory mechanism for elevating your program as needed instead of the whole executable all the time. For my particular purposes, I just needed global elevation, but the COM factory is a much more elegant solution if you only occasionally need access.

Disclaimer: Since I didn't see a step-by-step guide on how to do this anyway, I threw this together as I figured out what was going on. If you have any questions, ask away and I'll try to help.

Comments

Anonymous said…
Thank you for the information, however the manifest contents you show are not valid XML and will not work correctly. There is, for example, no closing tag for the assembly tag.
Marshall Fryman said…
SJB -

I'll have to go back and see why the manifest looks like that. Basically, I exported the manifest from Delphi 2007 and modified it as I needed it. I then linked it back in and voila. I'm not sure if this is a Delphi quirk or a Microsoft quirk.

Thanks for pointing it out though.

m
Anonymous said…
Thanks, you have given me hope. Life is not pointless after all.

- Notra Damus
Notra Damus said…
My journey brings me back, my friend. The XML you have posted above is badly formatted and does not work on Vista. So, here is the corrected XML brought to you by none other than yours truly, moi:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity

type="win32"

name="PDFPrint"

version="1.0.0.0"

processorArchitecture="*" />

<dependency>

<dependentAssembly>

<assemblyIdentity

type="win32"

name="Microsoft.Windows.Common-Controls"

version="6.0.0.0"

publicKeyToken="6595b64144ccf1df"

language="*"

processorArchitecture="*" />

</dependentAssembly>

</dependency>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">

<security>

<requestedPrivileges>

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

</requestedPrivileges>

</security>

</trustInfo>

</assembly>
Alan said…
Hi: sorry for the belated reply - great post.

I'd like to visit the last link you posted, but I'm being told "This blog is open to invited readers only", is that new, or do I have to ingratiate myself with the blog author in order to access it? ;)

Thanks in advance.
Marshall Fryman said…
Alan -

That's new. It used to work. I'm getting the same thing now. I don't have any method of contact Aleksander, do you?

Thanks,
m
Alan said…
I don't I'm afraid - I did come across a mirror of the article after a bit of investigative Googling, but I rather suspect it's an unsanctioned copy, see:

http://www.zhou73.cn/index.php/article/zhou73/2009-02-18/196.html
Anonymous said…
I was able to debug the elevated application by running D2007 as administrator

Mark B.
Jack said…
Sorry but I don't understand,
the manifest that Notra Damus posted is 1 file manifest or is the 2 minifests toghether?
And can I integrate the 2 manifests?

thanks at advance,

Jack

Popular posts from this blog

SMTP Mail and Indy (again)

Having spent a lot of time recently working on a ping scanner using Indy, I noticed that there's a lot of questions still on using SMTP with Indy. Let me first say that I am not an Indy expert. I get along with it successfully but find I still have to research things frequently. With the disclaimer out of the way, we can get to the offering. A while back I wrote a handy little unit to simply send a mail message with or without attachments and with or without providing authentication. It even has support for OpenSSL. I use this unit in a number of applications and have seen it successfully send hundreds of e-mails without issue. I recently added support for threaded message sending to take advantage of the multi-core system I'm now running on. This code has had a few additions (like the logger) that I've gleaned over time from various newsgroup postings, but I didn't record the authors so let me credit the anonymous Internet authors who support Indy. It's really amaz...

Detecting a virtualized environment

CubicDesign on delphi-talk.elists.org recently asked the question: "How do I know/detect if my software is running under Windows [or a virtual environment]?" Well, it turns out that it's a lot harder to tell than you would think. Apparently, the VM (VMware, Xen, Wine, etc.) doesn't really want you to be able to do this. At least not easily. For VMware, there is a decent little C routine called jerry.c that does the trick. Jerry actually uses a simple communication channel that VMware left open. It's not 100% foolproof since the admin can change the channel, but that's not likely going to happen unless the system is specifically designed to be a honeypot. If you're running on a honeypot and still have a legitimate reason for detection, you could look at the much more complex scoopy implementation which inspects how the system is actually virtualized using the SIDT CPU instruction instead of a communication channel. Another reference (red pill) is here . F...

Delphi Case with Strings

Zarko Gajic posted about this topic on his Delphi Tips recently showing how one could use a case statement with strings. His solution basically passes in an array on the stack and then iterates through it providing the index number of the matching string. I don't often want to do this, but the idea comes up occassionally enough that I thought I'd play with it a little. The first thing that struck me with this is that passing things on the stack is bound to be slow. Any time you can avoid memory allocation in your routines, do it. The way Zarko wrote his StringToCaseSelect routine created a COPY of the information on the stack. In my testing, just changing the CaseList: array of string to CaseList:const array of string improved the performance of the code by almost 30% for his example. Mind, I'm not using hyper-precise counters; however, it definitely makes a difference. Secondly, I was curious how the performance changed if I used the old stand-by: If then else. Using the ...

Copyright 2008-2022, Marshall Fryman