简体   繁体   English

如何在不访问CPAN的情况下使用CPAN模块?

[英]How to use CPAN modules without access to CPAN?

I am greatly disappointed every time I am forced to retrieve a module from CPAN. 每次我被迫从CPAN检索模块时,我都非常失望。 In most environments I work in, internet access is severely restricted or completely denied. 在我工作的大多数环境中,互联网访问受到严格限制或完全被拒绝。 All compilers have been removed during the OS hardening process. 在操作系统强化过程中​​已删除所有编译器。 And all digital storage media is scanned by a security team before entering or exiting the site. 在进入或退出网站之前,安全团队会扫描所有数字存储媒体。 Mind you, I understand security, and all of this is OK with me, but... 请注意,我理解安全性,所有这些对我来说都没关系,但......

What is the recommended or best practice for accessing code only CPAN modules provide. 仅访问CPAN模块提供的代码的建议或最佳做法是什么。

If I only need a snippet, a function, or a single string of functionality a module gives me, how can I extract "just what I need/want" without installing an entire module? 如果我只需要一个模块给我的片段,功能或单一功能串,如何在不安装整个模块的情况下提取“我需要/想要的东西”? Keeping in mind that I may be literally printing out, writing down, and typing in, to transfer the data from an off-site location with internet access. 请记住,我可能会打印出来,写下来并输入内容,以便通过互联网访问从异地位置传输数据。

When you can't access CPAN - how you want use it? 当您无法访问CPAN时 - 您想如何使用它? So, you can either: 所以,您可以:

  • when have internet access - you can install modules 什么时候上网 - 你可以安装模块
  • if havent, you can bring an minicpan on USB stick or soo 如果没有,你可以在USB记忆棒或soo上带一个minicpan
  • if this is not possible because security policy, you can only use eg you mobile phone to show source on CPAN and retype the needed parts manually 如果由于安全策略而无法实现,您只能使用手机在CPAN上显示来源并手动重新输入所需的部件
  • if neither is possible - you can at home print the source code on your tshirt and retype it in the work :) 如果两者都不可能 - 你可以在家里打印你的T恤上的源代码并在工作中重新输入:)
  • or, simply must programm all things yourself - by learning at home 或者,只需要自己编程所有东西 - 通过在家学习
  • or, find the better job :) 或者,找到更好的工作:)

EDIT: More serious approach 编辑:更严肃的方法

First, it is strange to have an company who developing with perl, but doesn't allow use CPAN. 首先,有一家公司使用perl进行开发,但不允许使用CPAN,这很奇怪。 Of course, I understand than direct access to a tons of unscanned sw is not acceptable for many companies, but in this case here should be exists some "company policies" - how to allow access. 当然,据我所知,直接访问大量未经扫描的sw对许多公司来说是不可接受的,但在这种情况下,这里应该存在一些“公司政策” - 如何允许访问。

Here are several questions: 以下是几个问题:

  • the hardening is at technical level only (firewalls etc) - so you can bring eg USB stick, CD or any other medium inside, or 硬化只在技术层面(防火墙等) - 所以你可以带上例如USB棒,CD或任何其他媒体,或
  • policy level - the policy does not allow using any external source 策略级别 - 策略不允许使用任何外部源

If it is at policy level - IMHO, you're out of luck. 如果它处于政策层面 - 恕我直言,你运气不好。 Simply when it is NOT ALLOWED using any external source - you can use really only the "print & retype" method. 简单地说,如果不允许使用任何外部源 - 您只能使用“打印和重新输入”方法。

Here is some possibilities: 这是一些可能性:

establish an company-wide local CPAN repository 建立公司范围的本地CPAN存储库

Create an local CPAN ( minicpan ) server with "trusted" modules. 使用“可信”模块创建本地CPAN( minicpan )服务器。 This repository can function as repository for locally developed modules too. 此存储库也可以作为本地开发模块的存储库。 In this case must exists some "auditing authority" (policies & procedures) how to get modules into the local repo. 在这种情况下,必须存在一些“审计权限”(策略和程序)如何将模块放入本地仓库。 IMHO, this can be the most useful way - when the company using perl on regular basis. 恕我直言,这可能是最有用的方式 - 当公司定期使用perl时。

Of course, mixing system-wide (default perl modules) with CPAN modules not the best idea. 当然,将系统范围(默认的perl模块)与CPAN模块混合不是最好的主意。 Therefore is possible to setup: 因此可以设置:

local::lib or build-prefix local :: lib或build-prefix

local::lib - create and use a local lib/ for perl modules with PERL5LIB. local :: lib - 使用PERL5LIB创建并使用本地lib / for perl模块。 Google for perl "local::lib" or something similar. 谷歌为perl "local::lib"或类似的东西。 Also read some other SQ questions: 另请阅读其他一些SQ问题:

Using local::lib is nice solution, because doesn't break system-wide perl modules. 使用local :: lib是很好的解决方案,因为它不会破坏系统范围的perl模块。 Of course, again - you will need some "auditing process" how to get modules inside . 当然,再次 - 您将需要一些“审核过程”如何在内部获取模块。

perlbrew perlbrew

Using your own built perl - perlbrew - is more general solution if the system hasn't installed perl. 使用您自己构建的perl - perlbrew - 如果系统尚未安装perl,则是更通用的解决方案。 You don't need root access for building your own perl. 您不需要root访问权来构建自己的perl。 Of course, here is still some problems (besides the auditing), eg the "missing compiler problem". 当然,这里仍然存在一些问题(除了审计之外),例如“缺少编译器问题”。

virtual machine 虚拟机

You can try setup an virtual machine for development (or isolated physical machine) with full CPAN access and develop here. 您可以尝试使用完全CPAN访问设置虚拟机进行开发(或隔离的物理机),并在此处进行开发。 When you finish the development, you can forward your work with all required modules to "auditing process". 完成开发后,您可以将所有必需模块的工作转发到“审核过程”。

other 其他

If you need only extract an function or a modules from the CPAN modules, do it on external machine. 如果只需要从CPAN模块中提取功能或模块,请在外部计算机上进行。 Extracting a function or some part is not a technical problem (when you know perl) it is more an license problem - using a part of modules in your work - you need cite the author. 提取函数或某个部分不是技术问题(当你知道perl时)它更像是一个许可证问题 - 使用你工作中的一部分模块 - 你需要引用作者。

For this you need fetch all needed functions - can find interesting this discussion . 为此,您需要获取所有需要的功能 - 可以找到有趣的讨论 Google for "perl functions dependencies" or something similar, or: 谷歌的“perl函数依赖”或类似的东西,或:

Maybe, you will find this discussion interesting too... 也许,你会发现这个讨论也很有趣......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM